有两种方式选择选项卡活动
我的应用程序有三个选项卡:A、B、C,它们具有三个不同的活动。
选项卡 A 包含列表视图。用户可以选择选项卡 B 或滚动 A 中的列表视图,选择一行将带他到选项卡 B 以及所选行的位置。
如何在选项卡 B 中检测到用户已选择一行或单击选项卡 B。单击选项卡 B 选择默认值, 而在 A 中选择一行会使 B 对数据执行一些特殊操作。我可以创建一个单独的活动,在选择一行时启动该活动,但这是代码重复,我更喜欢尝试找出 B 是否可以检测到它是如何启动的。
My app has three tabs, A, B, C that have three distinct activities.
Tab A includes a list view. User can either select Tab B or scroll the list view in A, selecting a row will take him to Tab B with the position of the selected row.
How can I detect in Tab B that the user has selected a row or clicked on Tab B. Clicking on Tab B selects a default,
whereas selecting a row in A makes B do something special with the data. I could create a separate activity that is launched when a row is selected, but that is code duplication and I prefer trying to find out if B can detect how it was launched.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用用于启动选项卡 B 的活动的 Intent 的 Extras 属性。
例如。
当您从列表中启动选项卡 B 时,单击:
在 TabB 的 onCreate(或类似位置)中:
Use the Extras attribute of the Intent you use to launch tab B's Activity.
eg.
When you launch Tab B from a list click:
in TabB's onCreate (or somewhere similar):