android -Fragments - onConfigurationChanged - 可以仅更改布局吗?
我有一个与片段相关的问题,更改片段布局的唯一解决方案是删除旧实例并替换为新实例? 我有两种布局,一种用于纵向,一种用于横向 - 我想保留所有信息(数据)并且仅替换调用 onConfigurationChanged() 方法的布局,但我无法强制片段重新创建布局。
谢谢,洛兰德
I have a question related to fragments, the only solution to change the fragment layout it's if I remove the old instance and replace with new one?
I have two layout's one for portrait and one for landscape - I want to keep all the information's(data) and only replace the layout the onConfigurationChanged() method is called, but I can't force the fragment to recreate the layout.
Thanks, Lorand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你是否只能更改布局而不重新加载数据。
我的解决方案是
不要放置 android:configuration='orientation'
在manifest.xml中。
旋转屏幕时,通常会调用 onCreateActivity ,它将采用良好的布局并重新加载您的数据。
I don't know whether you can only change your layout without reloading your data.
My solution is
Don't put android:configuration='orientation'
in the manifest.xml.
When rotating screen, normally onCreateActivity will be call and it'll take the good layout AND RELOAD your data.