开发者

How to get an EditText field prefilled after hitting the back button

开发者 https://www.devze.com 2023-01-05 21:33 出处:网络
I have a setup view where the user can enter their name and email and click done when they are finished which navigates them to another activity1.When they are in activity1, and they hit the soft back

I have a setup view where the user can enter their name and email and click done when they are finished which navigates them to another activity1. When they are in activity1, and they hit the soft back button on the phone, it takes them screen where they entered their name and email. However, the name and email EditText fields are blank.

In the开发者_StackOverflow中文版 view where the name and email are entered I looked to see if onStart, onCreate, OnPause, onResume,... where being called after the back button was hit, but they are not.

Do you know how I can make it so that the EditText fields have the information that was previously entered.


Well, you could store the data in a singleton class, and when they go back to the activity, it checks if those values exist and populate the EditText.

Here's how you can override the onresume:

@Override
  public void onResume() {
    super.onResume();

    // do whatever you need to do here
  }
0

精彩评论

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