Hassan Mokdad
Hassan Mokdad

Reputation: 5902

Android Activity losing state (scroll position and text entered into forms) when starting another activity

I am using the following code to open a new Activity from my current running activity

Intent intent = new Intent(this.getApplicationContext(),
            ImagePreview.class);
    intent.putExtra("imageName", item.getImageName());
    this.startActivityForResult(intent, 0);

When I press the back button, the old activity should reatain it's basic state values (scroll position and text entered into forms) but it is not! what could be the issue? I used the code many times before and never the problem has occured.

Thanks

Upvotes: 0

Views: 175

Answers (1)

Julian Suarez
Julian Suarez

Reputation: 4521

If you are using EditText be sure to set up an android:id atttirbute on your xml (or set an Id programatically ) so it can save its text automatically. For the ScrollView I imagine it could be the same, although I'm not sure since I have not done that myself

Upvotes: 1

Related Questions