android -Fragments - onConfigurationChanged - 可以仅更改布局吗?

发布于 2024-12-25 20:54:26 字数 153 浏览 6 评论 0原文

我有一个与片段相关的问题,更改片段布局的唯一解决方案是删除旧实例并替换为新实例? 我有两种布局,一种用于纵向,一种用于横向 - 我想保留所有信息(数据)并且仅替换调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳钉梦 2025-01-01 20:54:26

我不知道你是否只能更改布局而不重新加载数据。
我的解决方案是
不要放置 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文