安卓问题集锦 1 分钟

自建TabHost,为什么R.java中无tabhost的id

问题出在你的xml布局定义中的这一行: android:id=”@android:id/tabhost” 如果是想不用android的tabhost的id,那么这行应该改为: android:id=”@+id/tabhost” 如果确实要用android的定义,又要找到这个窗口,那么应该改代码中的这行: TabHost mTabHost = (TabHost)findViewById(R.id.tabhost); 应该改成 TabHost mTabHost = (TabHost)findViewById(android.R.id.tabhost);

转载请注明出处:http://www.jiliuke.com/2014/10/31/e8-87-aa-e5-bb-batabhost-ef-bc-8c-e4-b8-ba-e4-bb-80-e4-b9-88r-java-e4-b8-ad-e6-97-a0tabhost-e7-9a-84id/