I have a FragmentTabHost and i have a usertab added like this:
mTabHost.addTab(mTabHost.newTabSpec("usertab").setIndicator(uti), LoginTab.class, null);
When the user is loggedin i want to change the class for that tab to UserTab which i do like this:
getSupportFragmentManager()
.beginTransaction()
.replace(android.R.id.tabcontent, new UserTab(), "usertab")
.commit();
however if the user is on a different tab the content of the tab the user is on gets changed (it's just replacing the content of the tabcontent layout which is connected to the currently selected tab), i was hoping that adding the tag parameter in the replace function would do the trick, but it doesn't (what does it do anyway?, cause it doesn't do anything different then when i don't use it).
Is my only option to programmatically change the tab to the usertab before i commit the transaction or is there a better way?
(this is my first toying around with the whole fragment phenomenon by the way)
You should change the FragmentTabHost for TabLayout paired with a viewpager, this is a good example; if you cannot replace the fragmentTabHost i recommend you to do the fragment transactions without the .replace(), because it has unexpected behaviour when popping the backstack transactions which could be the problem youre seeing now