How can I maintain fragment state when added to the back stack?
问题 I\'ve written up a dummy activity that switches between two fragments. When you go from FragmentA to FragmentB, FragmentA gets added to the back stack. However, when I return to FragmentA (by pressing back), a totally new FragmentA is created and the state it was in is lost. I get the feeling I\'m after the same thing as this question, but I\'ve included a complete code sample to help root out the issue: public class FooActivity extends Activity { @Override public void onCreate(Bundle