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

posted @ 2016-05-19 19:51  StevenLuke  阅读(89)  评论(0编辑  收藏  举报