开发者

Open A New Layout, Then Return to the Previous

开发者 https://www.devze.com 2023-04-08 15:05 出处:网络
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.

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 info开发者_开发百科rmation previously inputted into main.xml lost?

Thank you in advanced.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号