TabHost remove Tab

by Ahmy » Mon, 16 Jun 2008 12:04:32 GMT

Sponsored Links
 Hello all

I'm successfully create a tab using TabHost and TabHost.TabSpec.
i found an addTab method but not removeTab.
there is also clearAllTabs(boolean).  but that will remove all the
is there any way to remove tab by its tag name ?

oh and i created the tab programatically or by code.

thanx b4,


TabHost remove Tab

by Josh Guilfoyle » Thu, 19 Jun 2008 10:02:31 GMT

 You can't currently.  I don't believe this is an inherent deficiency
in the design of TabHost, but rather that you ought not construct a UI
that behaves this way.  You are presuming to reveal a tab to the user
and then hide it through some event.  Will this be extremely clear to
your user why they have lost functionality?  Perhaps disabling tabs
makes more sense for your UI, or designing separate activities


Sponsored Links

TabHost remove Tab

by Ahmy » Tue, 24 Jun 2008 19:20:11 GMT

 mm.. basically im creating a client messenger. the tab reveal when
user wants to chat to some user.
and the tab close when user no longer want to see the chat window.
the reason im doing this is because i just wanted a single activity.
and its only for testing my client messenger library.
single activity can reduce the complexity because the activity only
for a sample of how using this library.

thanks any way


TabHost remove Tab

by Mark Murphy » Tue, 24 Jun 2008 23:03:50 GMT


Have you tried removeView() on both the TabHost and TabWidget? That 
method should be available on both, since they inherit from ViewGroup. 
Calling it to remove the tab details and the tab itself from the host 
and widget, respectively, might do the trick.

If that doesn't work -- and I hate to sound like a broken record here -- 
  you could "roll your own" tab-like view using ViewFlipper, where 
removeView() should work.

Mark Murphy (a Commons Guy) 
Warescription: All titles, revisions, & ebook formats, just $35/year


TabHost remove Tab

by Guillaume Perrot » Wed, 25 Jun 2008 00:16:17 GMT

 I had the same problem.
I used removeViewAt(int position) on the TabWidget and it worked for
The same didn't work directly on TabHost (ArrayOutOfBoundException).


TabHost remove Tab

by Guillaume Perrot » Wed, 25 Jun 2008 21:06:46 GMT

 In fact it seems to have side-effects to use
I have two tabs : A B
I delete B, i add C (at the end).
When clicking on C (the indicator is good), i see B's content which
was removed !
When adding tab D at the end, i see C's content !
And so on...
I think it's currently impossible to remove a tab making TabHost
completely useless for creating a IM application... I'm gonna think of
a different way to build my UI (like using buttons to replace tabs and
switching the view when clicking on a button).


Other Threads

1. OOT : Best gadget to have after Blackberry and Android?

Sesuai judul, gadget to have after Blackberry and Android? Saya kpikiran
ipad... trus kpikiran ps3 or xbox.. ada ide yg kren suhu2? Saya kurang
mendalami gadgets..



2. What is the best way to send data from Android Application to a Remote MySQL Database?

What is the best way to send data from Android Application to a Remote
MySQL Database?


3. lock sqlite file

4. Feature Graphic, High Resolution Application Icon and Promotional Video.

5. Stupid market.

6. Tanya aplikasi video call

7. How can I split pdf file into png / jpeg image