Android 标签页和意图

发布于 2024-09-14 09:53:32 字数 196 浏览 2 评论 0原文

我有一个自动完成文本框,用户可以在其中进行选择。从这里我想加载一个基于用户选择的选项卡式布局。问题是我无法找到一种干净的方法将该选择传递给每个选项卡。目前,我可以将意图传递给“tabhost”活动,然后显式传递给每个子活动,但是对我来说,这似乎是混乱的迭代代码!所以基本上我怎样才能将我的意图数据包干净地传递到选项卡活动?高效!伪代码也非常受欢迎;)

干杯伙计们

I have a auto-complete textbox in which the user makes a selection. From here I want to load a tabbed layout which is based on the user selection. The problem is I cant figure out a clean way to pass that selection to each of the tabs. At the moment I can pass an intent to the 'tabhost' activity and then pass to each child activity explicitly, however this just seems like messy iterative code to me! So basically how can I pass my intent data bundles to the tabs activities cleanly & efficiently! Psuedo code is also very welcome ;)

Cheers guys

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩世 2024-09-21 09:53:32

听起来你需要广播一些信息。您将能够在您希望收到通知的任何活动/服务中设置广播接收器。

在线阅读有关 Broadcastreceiver发送广播

Sounds like you need to broadcast some information. You than will be able to set broadcast receivers in any activity/service you would like to get notified.

Read more online about Broadcastreceiver and about send broadcast

紫南 2024-09-21 09:53:32

您可以将选择存储为 SharedPreference,然后从任何活动中获取值。想到的第二个选项是将所选值保存在应用程序上下文中,也可以从任何活动轻松访问该值。

You can store the selection as SharedPreference and then just obtain the value from any activity. Second option that comes in mind is saving the selected value on the Application context which is also easily accessible from any activity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文