从 Android TabHost 中的选项卡活动更新选项卡 [英] Update tabs from a tab's activity in a Android TabHost

查看:41
本文介绍了从 Android TabHost 中的选项卡活动更新选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 TabActivity 并且将有 3 或 4 个标签.

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

在 TabA 中,我想要一个 ExpandableListView,它将列出产品.我希望 TabC 充当一种购物车",可能带有自己的 ListView.

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.

有没有办法从 Activity 与 TabHost 交互?我希望能够单击 TabA 内的按钮并更新它并切换到 TabC.这可能吗?我可以让 Tab 的活动调用其父方法吗?

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?

推荐答案

如果您将选项卡实现为视图,而不是单独的活动,这将更简单,运行速度更快,占用内存更少,并且是更好的解决方案恕我直言.

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.

话虽如此,在 Tab A Activity 中,调用 getParent() 以获取 TabActivity.然后,你可以使用disretrospect所指出的方法.

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.

这篇关于从 Android TabHost 中的选项卡活动更新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆