문제

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