tags:

views:

528

answers:

1

Hi,

I have a TabActivity. Each tab points to a sub activity. Works great.

Is there any clever way to refresh one of the activity tabs? I just want to 'restart' the activity in tab #3 for example. Not sure of a good way to do this other than building in refresh support to the activity itself, or clearing ALL the tabs and recreating all of them.

Thanks

A: 

I've not tried this myself, but typically you access each individual tab's Activity using the LocalActivityManager. This can be retrieved in a TabActivity by using getLocalActivityManager().

It looks like you should be able to use destroyActivity() and startActivity() to restart an Activity, though I'm not exactly sure if this will work (as I've not done it myself). One important thing to note is that the id of the Activity will be equivalent to the tag you set for the tab (e.g., the String you provided to TabHost.newTabSpec(String)).

LocalActivityManager manager = getLocalActivityManager();
manager.destroyActivity("tab3", true);
manager.startActivity("tab3", new Intent(this, ThirdTab.class));
Daniel Lew
Awesome thanks Daniel, I'll give it a try!