打开新布局,然后返回到上一个布局
我有我的 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有三种方法可以做到这一点
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 finishdescribe Activity
main Activity will be resume without and lost of data2) 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 Activity3) You can also save data to preference file
只需将您的信息存储在 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.