Android 标签页和意图
我有一个自动完成文本框,用户可以在其中进行选择。从这里我想加载一个基于用户选择的选项卡式布局。问题是我无法找到一种干净的方法将该选择传递给每个选项卡。目前,我可以将意图传递给“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来你需要广播一些信息。您将能够在您希望收到通知的任何活动/服务中设置广播接收器。
在线阅读有关 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
您可以将选择存储为 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.