如何在销毁-创建周期之间保存 tabhost 选项卡
应用程序有一个通过 TabActivity 管理的 tabhost。 它可以选择在运行时添加选项卡。
假设在运行时添加了 5 个选项卡并显示不同的活动。
当我旋转屏幕时,活动会经历破坏和创建的循环。 我想保持用户在运行时添加的选项卡在此周期内可用。
Application has a tabhost managed through TabActivity.
It has option to add tabs at runtime.
Say 5 tabs are added in runtime and different activities are shown.
When I rotate the screen the activity undergoes the cycle o destroy and create.
I want to maintain the tabs added by user in runtime to be available during this cycle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是更改您的清单,表明您将自己处理方向更改。
其作用是告诉系统不要在方向改变时重新创建活动。然后,您可以覆盖 OnOrientationChanged 以修改任何配置更改。
如果您不需要任何显式更改,也可以将其省略。
如需进一步阅读:Android 运行时更改
The easiest way to do this is to change your Manifest to say that you will handle the orientation change yourself.
What this does is tell the system to not recreate the activity on orientation change. You can then override OnOrientationChanged to modify any configuration changes.
You can also leave it out if you don't need any explicit changes.
For further reading: Android Runtime Changes