打开新布局,然后返回到上一个布局

发布于 2024-12-06 12:58:55 字数 318 浏览 2 评论 0原文

我有我的 main.xml 布局。从这里,用户填写信息,然后单击一个按钮,将他们带到另一个 describe.xml 布局。

问题是:我如何获得它,以便您可以按 main.xml 上的按钮打开 describe.xml,然后当您按 main.xml 上的按钮时code>describe.xml 后,您返回到 main.xml 时,之前输入到 main.xml 中的任何信息都没有丢失吗?

提前谢谢您。

I have my main.xml layout. From here, the user fills in information, and is to click a button that should bring them to another describe.xml layout.

The question is: how do I get it so that you can press a button on main.xml to open up describe.xml, then when you hit a button on the describe.xml, you return to main.xml without any information previously inputted into main.xml lost?

Thank you in advanced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

情魔剑神 2024-12-13 12:58:55

有三种方法可以做到这一点

1) 当你启动 Activity describe Activity 时,不要 finish() main Activity ,这样当你完成时 describe Activity > 主 Activity 将在没有数据丢失的情况下恢复

2) 如果您想从描述活动获取数据到主活动,您可以通过调用 startActivityForResult 启动描述活动,并且可以从描述活动获取结果到主活动活动

3) 您还可以将数据保存到首选项文件中

There are three ways to do this

1) When you start Activity describe Activity don't finish() main Activity so that when you finish describe Activity main Activity will be resume without and lost of data

2) If you want to get data from describe Activity to main Activity you can start describe Activity by calling startActivityForResult and you can get result from describe Activity to main Activity

3) You can also save data to preference file

去了角落 2024-12-13 12:58:55

只需将您的信息存储在 SharedPreference 或文件或重写 onPaused() 方法中的某个静态字段中,然后在 onResume() 方法中读出并填充信息即可。

Just store your information in a SharedPreference or a file or some static field in the override onPaused() method, and read out and fill information in the onResume() method.

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