Vikram
Vikram

Reputation: 1092

How to clear old tabs and add new tab on tabhost

I have to create tab bar in my application in which i have to navigate between activities under single tag. So that i tried many ways one of which is to clear all tabs from tabhost and create new tabs and add on tabhost but it gives me unexpectedly close error. can you help me... Thank You In Advance. Vikram Kadam

Upvotes: 1

Views: 7938

Answers (2)

Kevin Bradshaw
Kevin Bradshaw

Reputation: 6427

One possible cause is that when you remove your tabs the current tab needs to be set to 0.

in other words, if you try to remove your tabs while the current selected tabs is greater than 0 you will cause an error, so you need to reset your current tab to 0 index before you remove the tabs with clearAllTabs();

So... do something like this:

tabHost.setCurrentTab(0); 
tabHost.clearAllTabs();

Hope this helps

Kev

Upvotes: 15

Keenora Fluffball
Keenora Fluffball

Reputation: 1686

What kind of error is that?

mTabHost.clearAllTabs();

This should remove all the tabs. Probably it could be, that you need at least one tab to stay in the tabHost, but I do not think so. What does LogCat say?

Upvotes: 1

Related Questions