سؤال

When navigating using the Up button, the state of the Parent Activity is not preserved. The state is preserved perfectly when I use the back button to navigate to the Parent Activity. Is this the intended behavior? If not, what step am I missing to make the Parent Activity preserve its state (the text in EditTexts, for example)?

هل كانت مفيدة؟

المحلول

If you're just looking to save values in the EditText fields, you should look into saving values for the activity into your SharedPreferences.

Alternately, you can always call the 'onBackPressed' method from your Up button. The Up button is handled just like any other action bar icon, so there is a call made to onOptionsItemSelected(MenuItem item). You just need to check for the case android.R.id.home in the item's id and call the onBackPressed there

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top