我正在使用 TabHost.On 加载我已将第二个选项卡设置为默认选项卡。我工作正常,但与第二个选项卡内容一起显示的第一个选项卡内容。如何删除第一个选项卡内容。这仅显示在默认的第二个选项卡上,而不是第一个选项卡上。
我尝试了以下代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Inflate the layout
setContentView(R.layout.tabs_viewpager_layout);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
// Initialise the TabHost
this.initialiseTabHost(savedInstanceState);
if (savedInstanceState != null) {
mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab")); //set the tab as per the saved state
}
// Intialise ViewPager
this.intialiseViewPager();
mViewPager.setCurrentItem(2);
}
我的 initialiseTabHost 函数
private void initialiseTabHost(Bundle args) {
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.setup();
TabInfo tabInfo = null;
TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator("",getResources().getDrawable(R.drawable.info_icon)), ( tabInfo = new TabInfo("Tab1", Info.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator("",getResources().getDrawable(R.drawable.search_icon)), ( tabInfo = new TabInfo("Tab2", Search.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator("",getResources().getDrawable(R.drawable.home_icon)), ( tabInfo = new TabInfo("Tab3", Home.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
mTabHost.setCurrentTab(2);
TabsViewPagerFragmentActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab4").setIndicator("",getResources().getDrawable(R.drawable.member_icon)), ( tabInfo = new TabInfo("Tab4", Profile.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
mTabHost.setOnTabChangedListener(this);
}
有人可以帮我吗?
谢谢,