There is a method to add a tab in TabHost
as well as clear all tabs, but there are no APIs to remove one single tab.
F开发者_如何学Pythonollowing the logic in clearAllTabs
tried to
tabwidget.removeViewAt(index);
tabHost.getTabContentView().removeViewAt(index)
After this the behaviour is strange. I assume that is because the mTabSpecs
still contain the tabspec reference. mTabSpecs
is a private variable in TabHost
and there are not get methods to get a handle to this.
How to resolve the issue if one wants to close a single tab, and yes I have tried to clear all the tabs and add back all the tabspecs. It does not work for my usecase where some views contains some information regarding a session. If I recreate those tabspecs, I will go back to the starting point in those views.
You can try to set Visibility
of the Tab
that you want to close
to View.GONE
.
resolved with the View.GONE but with method which specifically checks for the visibility before counting the tabs. drawback is the index of the view cannot be changed.
精彩评论