0

I'm looking for a method to destroy a particular tab and the attached activity that I've started in it and I can't seem to find it in the docs for TabHost or TabWidget. I found this question How to remove tab from TabHost but this doesn't make too much sense to me explained in the way that it is. I have also found this method Removing a tab and the activity (intent) inside of it from a TabHost but it seems far too convoluted to be a proper solution. Is there some method I'm missing that gets rid of the TabWidget view? I'm new to coding so maybe I'm just not understanding these two questions fully.

Thanks in advanced.

Community
  • 1
  • 1
Dylan
  • 563
  • 4
  • 15
  • This looks like it should work, but it doesn't. :( `private void closeTab() { // TODO: Define method for closing a single tab with tabTag mTabHost.removeView(mTabHost.getCurrentTabView()); }` – Dylan Jun 19 '11 at 19:48

1 Answers1

0

Below function just clears all the tabs from your TabWidget and you have to create tabs again in requestLayout

public void clearAllTabs() {
  mTabWidget.removeAllViews(
  initTabHost();
  mTabContent.removeAllViews();
  mTabSpecs.clear();
  requestLayout();
  invalidate();
}
success_anil
  • 3,659
  • 3
  • 27
  • 31
  • That's what I figured. There's got to be a better way than that, right? That too seems convoluted. Are you aware of a different way to achieve this? – Dylan Jun 19 '11 at 14:43