简体   繁体   中英

Back button to a fragment

I have a main activity with 2 fragments. One of the fragments is a form. After submitting the form, a new results activity is a launched which has a back navigation button. When I press this back button, I am taken back to the form, but my form is cleared. I want to retain all the data which I entered initially before submitting. How can I achieve this?

You have to remember about active / fragment lifecycle. When you back to your activity / fragment you have to refresh method @onResume. So if you forgot about @onResume method you have to implement overridden and put there your missing methods.

通过设置将片段保存为清单文件中的singleTop的活动的launchMode,我能够解决此问题。

android:launchMode="singleTop"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM