开发者

How to clear old tabs and add new tab on tabhost

开发者 https://www.devze.com 2023-01-11 05:44 出处:网络
I h开发者_如何学Cave 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 c

I h开发者_如何学Cave 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


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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消