如何从其他活动动态更改 tabhost 的指示器
我有一个包含 5 个选项卡的选项卡主机(星期一....星期五)。 我想从其他活动动态更改指标(使用按钮) 有没有人有解决办法 提前致谢
I have a tabhost that contains 5 tab (Monday .... Friday).
I want to change the indicators dynamically from other activities (using a button)
Does any one have a solution
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你不能直接这样做。相反,尝试将选项卡主机的配置存储在某处。因此,当您打包选项卡活动并点击 onResume() 方法时,您可以对更改的选项卡配置做出反应并重新排列选项卡。
存储选项卡配置的位置取决于该配置是否应在整个应用程序重新启动后继续存在。当您不关心应用程序是否使用标准配置重新启动时,您可以使用 Application 类来存储这些信息。如果选项卡更改的配置在重新启动后也应该可用,则您必须以某种方式将其保留在设备上。您可以在 Android 开发者页面。
I think you couldn't do this in directly. Instead try to store the configuration of you tab host somewhere. So when you came pack you tab activity and hit the onResume() method you can react on the changed tab configuration and rearrange the tabs.
The location where you store the tab configuration depends on whether the configuration should survive the restart of the whole application. When you don't care that the application is restarted with the standard configuration you could use a Application class to store this information. If the tab changed configuration should also be available after an restart, you will have to persist it somehow on the device. You can read about the different options you got on the Android developer page.
获取 tabIndicator 视图。它通常由 ImageView 和 TextView 组成,除非您有自己的自定义 TabIndicator。
相对布局内的 textView 目前是第二个子视图(注意这可能会改变),除非您有自定义 tabIndicator 视图。
如果要更改图像,请获取位置 0 处的 imageView
Get a hold of the tabIndicator View. It usually consists of an ImageView and a TextView unless you have your own custom TabIndicator.
The textView inside the relative layout is currently the 2nd child (careful this might change) unless you have a custom tabIndicator view.
If you want to change the image get the imageView at location 0