use this setRetainInstance(true) in that fragment to which you want to save state. within onCreate();
On Saturday, December 29, 2012 1:38:01 PM UTC+5:30, Dmitriy F wrote: > > I have a couple of fragments which substitute one for another. The UI of > these fragments changes and I need to hold it's new state. So the code > looks pretty trivial: > > FragmentManager fragmentManager = getSupportFragmentManager(); > FragmentTransaction fragmentTransaction = fragmentManager > .beginTransaction(); > > if (mStepTwo == null) { > mStepTwo = new QuizStepTwo(); > mStepTwo.setListener(mStepTwoListener); > } else { > fragmentTransaction.remove(mStepTwo); > } > > fragmentTransaction.replace(R.id.step_holder, mStepTwo); > fragmentTransaction.addToBackStack("second_step"); > > fragmentTransaction.commit(); > > However when I replace the second step with the first, for instance by > pressing the back-button,- its' UI state rolls back to initial. > > How do I hold the state ? OnSaveInstanceState ? or something more > comfortable ? > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en