0
我正在使用TabHost.On加載我已經將第二個選項卡設置爲默認選項卡。我工作正常,但隨着第二個標籤內容第一個標籤的內容也顯示出來。如何刪除第一個標籤內容。這僅在默認的第二個選項卡上顯示,而不在第一個選項卡上顯示。使用Tabhost顯示在第二個選項卡中的第一個選項卡內容android
我曾嘗試下面的代碼:
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);
}
有人可以請幫助我?
謝謝,
寄存器中的manifest.xml第一和第二活動並創建在佈局文件夾的第一和第二類視圖中的兩個XML文件。 – ashu
如果這適用於喲,請投票支持 – ashu
我正在使用片段。我認爲這一定會造成問題。 – asifa