关于android的xml布局文件的id不明白的地方:
有的控件用了系统id,如下红色的代码:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</TabHost>问题:
为什么需要系统id?有什么好处?不是很理解。id是为了能唯一标识某一控件,如果TabHost有两个呢,都用“@android:id/tabhost”就出问题了啊请教!
有的控件用了系统id,如下红色的代码:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</TabHost>问题:
为什么需要系统id?有什么好处?不是很理解。id是为了能唯一标识某一控件,如果TabHost有两个呢,都用“@android:id/tabhost”就出问题了啊请教!
至于为什么要使用系统ID,是因为继承于TabActivity的窗口时候,基类TabActivity就是通过系统ID索引的
<TextView android:id="@+id/android:empty"to fff32165:我这有一个例子的xml有两个TabWidget,都用了同样的id,系统id:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/background">
<LinearLayout android:orientation="vertical" style="@style/TabStyle"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<TabWidget android:id="@android:id/tabs" android:layout_height="48dp" android:layout_width="match_parent"></TabWidget>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp" >
</FrameLayout>
</LinearLayout>
</TabHost>