CharSequence str=getString(R.String.str);
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:autoLink="all" android:text="百度:http://www.baidu.com" />
TextView tv=(TextView)findViewById(R.id.mytextview);
tv.setText();
color.xml
<?xml version="1.0" encoding="UTF-8"?> <resources> <drawable name="white">#ffffff</drawable> <drawable name="black">#000000</drawable> <drawable name="mid">#C2CE99</drawable> </resources>
mail.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:background="@drawable/white" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/lable" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@drawable/black" android:text="@string/height" />
</LinearLayout>
通过java代码来改变颜色
Resources resources=getBaseContext().getResources(); Drawable white=resources.getDrawable(R.drawable.mid); TextView tv=(TextView)findViewById(R.id.lable); tv.setBackgroundDrawable(white); tv.setTextColor(Color.RED);
