Replace fragment in another Activity Android -
I have two fractal activites. I can go from activity (A) to activity (B), and various pieces After the change, (B) has a home button that should return the first piece of activity (A). My code is:
btnHome.setOnClickListener (New View.OnClickListener () {@Override Public Zero onClick (see arg0) {Finish}; MainActivity.fragmentManager .beginTransaction () .replace (R .id.content_frame, new first restriction ()). AddToBackStack (null) .commit ();}}); Which is fragmentManager : FragmentManager fragmentManager = getSupportFragmentManager (); In MainActivity, but I get an error below:
java.lang.IllegalStateException: onSaveInstanceState, this action can not be executed < / code> How can I handle it?
"itemprop =" text "> OK, I got his place from commitAllowingStateLoss () Committed with () . So it became like this: MainActivity.fragmentManager .beginTransaction () .replace (R.id.content_frame, new firstFragment ()) .addToBackStack (zero) .commitAllowingStateLoss ();
Comments
Post a Comment