自定义TabHost中findViewById()方法无法获取到ID
在xml中Tabhost、TabWidget、FrameLayout的Id都是系统默认生成那种,如下:
<TabHost
android:id="@android:id/tabhost"
。。。。。
<TabWidget
android:id="@android:id/tabs"
。。。。。
<FrameLayout
android:id="@android:id/tabcontent"
。。。。。
但是activity中调用findViewById()方法却调用不到ID
findViewById(R.id.tabhost);
findViewById(R.id.tabs);
findViewById(R.id.tabcontent);======》》飘红!
求大神!! Android
[解决办法]
系统默认的id,你知道在layout中加入了android默认的,@android:id/tabhost. 在查找时也要加入android前缀的,比如android.R.id.tabhost