Update tabs from a tab's activity in a Android TabHost

Josh Lillie picture Josh Lillie · May 31, 2010 · Viewed 21.1k times · Source

I have a TabActivity and am going to have 3 or 4 tabs.

In TabA, I would like to have an ExpandableListView, which will list products. I would like TabC to act as a sort of "shopping cart", probably with a ListView of itself.

Is there a way to interact with the TabHost from the Activity? I would like to be able to click a button inside of TabA and have it update and switch to TabC. Is this possible? Can I get the Tab's activities call its parents methods?

Answer

CommonsWare picture CommonsWare · May 31, 2010

If you implement your tabs as views, rather than individual activities, this would be far simpler, run faster, take up less memory, and be a better solution IMHO.

That being said, in the Tab A Activity, call getParent() to get at the TabActivity. Then, you can use the methods pointed out by disretrospect.