Android TabHost
Open Declarationvoid android.widget.TabHost.setup()
Call setup() before adding tabs if loading TabHost using findViewById(). However: You do not need to call setup() after getTabHost() in TabActivity. Example:
mTabHost = (TabHost)findViewById(R.id.tabhost);
mTabHost.setup();
mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
上面所说的是 mTabHost在使用(addTab())前要调用setup()方法。
另外相应的xml视图文件里,TabWidget的id是Android自带的@android:id/tabs
FrameLayout的ID也是Android自带的@android:id/tabcontent
Call setup() before adding tabs if loading TabHost using findViewById(). However: You do not need to call setup() after getTabHost() in TabActivity. Example:
mTabHost = (TabHost)findViewById(R.id.tabhost);
mTabHost.setup();
mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");