@ Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.bottom_tabs);
ActionBar actionBar = getActionBar();
// set the Icon
actionBar.setIcon(R.drawable.ic_launcher);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this , getSupportFragmentManager() , R.id.realtabcontent);
tabIndicator1 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo , mTabHost.getTabWidget() , false);
title = (TextView) tabIndicator1.findViewById(android.R.id.title);
title.setText("Infos");
tabIndicator2 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo , mTabHost.getTabWidget() , false);
title = (TextView) tabIndicator2.findViewById(android.R.id.title);
title.setText("Info");
tabIndicator3 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo , mTabHost.getTabWidget() , false);
title = (TextView) tabIndicator3.findViewById(android.R.id.title);
title.setText("Development");
tabIndicator4 = LayoutInflater.from(this).inflate(R.layout.apptheme_tab_indicator_holo , mTabHost.getTabWidget() , false);
title = (TextView) tabIndicator4.findViewById(android.R.id.title);
title.setText("Charging");
mTabHost.addTab(mTabHost.newTabSpec("infos").setIndicator(tabIndicator1) , InformationTabs.class , null);
mTabHost.addTab(mTabHost.newTabSpec("info").setIndicator(tabIndicator2) , InfoFragment.class , null);
mTabHost.addTab(mTabHost.newTabSpec("development").setIndicator(tabIndicator3) , DevelopmentTab.class , null);
mTabHost.addTab(mTabHost.newTabSpec("charging").setIndicator(tabIndicator3) , ChargingTab.class , null);
}
LogCat says that the specified child already has a parent. and i should call removeView() on the child`s parent first...
I just don`t get it?!
I know that the problem is that i am using 2 layouts here, but how can i solve it....
Thanks for any hints
This kind of error happens when you try to add a view to a parent and it was already added to another.
You're adding tabIndicator3
two times. Replace this code:
mTabHost.addTab(mTabHost.newTabSpec("charging").setIndicator(tabIndicator3) , ChargingTab.class , null);
by this:
mTabHost.addTab(mTabHost.newTabSpec("charging").setIndicator(tabIndicator4) , ChargingTab.class , null);