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

馋奶兔 提交于 2019-11-27 15:33:58

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.

Randy V

Try to use this code to change activity within a tab:

TabActivity parent = (TabActivity) getParent();
TabHost tabhost = parent.getTabHost();
tabhost.setCurrentTab(0);
m6tt

You can call getTabHost from a TabActivity, see public TabHost getTabHost().

See Tabhost for setCurrentTab, public void setCurrentTab(int index).

  1. In your Activity, use getParent() to get the TabActivity parent
  2. In your TabActivity class, use getLocalActivityManager().getActivity(tabId) to get the Activity object
  3. call the Activity object's method
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!