android中xml文件注意事项

xml文件android:id

<TabWidget

android:id="@android:id/tabs"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="0"

android:background="#ff000000"/>

调用时android:id

tabHost=(TabHost)this.findViewById(android.R.id.tabhost);

xml中android:text一般这样写

<TextView

android:text="正在保存书签..."

android:textColor="#ffffff"

android:textSize="18dip"

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

还有一种写法是android:text="@string/hello"

<TextView

android:text="@string/hello"

android:textColor="#ffffff"

android:textSize="18dip"

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>

在values文件夹中string.xml的这行的值

<stringname="hello">HelloWorld,MainActivity!</string>

相关推荐