如何为选项卡添加自定义布局?例如,我想在标签中添加图标和标题。以及自定义活动/非活动颜色。代码:
mTabHost = (TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup();
mViewPager = (ViewPager) findViewById(R.id.pager);
mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
TabSpec tab1spec = mTabHost.newTabSpec("tab1").setIndicator("Tab 1");
TabSpec tab2spec = mTabHost.newTabSpec("tab2").setIndicator("Tab 2");
mTabsAdapter.addTab(tab1spec, ConverterFragment.class, savedInstanceState);
mTabsAdapter.addTab(tab2spec, RatesFragment.class, savedInstanceState);
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
}