Wizard-style activities and onSaveInstanceState
I implemented several activities in a "wizard-style", that is, there's a next and a previous button at the bottom to navigate between them using:
Intent NextActivityIntent = new Intent(v.getContext(), FormN.class);
startActivity(NextActivityIntent);
The problem I'm facing is that when I go back to an Activity, the fields completed previously are empty.
The question is, is there a simpler way to keep displaying the field values other than intercepting the开发者_JAVA百科 onSaveInstanceState and onRestoreInstanceState events and save/restore every field manually ?
Use startActivityForResult instead of startActivity. The previous activity and its state would remain in the stack. For going back from your current activity use finish().
Ideally, you should code for onSaveInstanceState in case the phone gets re-oriented. Doesn't matter if you lock your phone orientation though.
精彩评论