0

The backstack is now:

[fragment 1] -> [fragment 2]

NearMe fragment = new NearMe();
FragmentManager frgManager2 = getFragmentManager();
frgManager2.beginTransaction().replace(R.id.content_frame,fragment).addToBackStack(null).commit();

But How to Back key using back

[fragment 2] -> [fragment 1]

frogatto
  • 28,539
  • 11
  • 83
  • 129
Parth Kathiriya
  • 137
  • 2
  • 4
  • 8
  • you want backpress of fragment?? Only the Activity have OnBackPress method. I have another Solution for using Fragment Its not proper But it works very well. If u need code tell me. Its really tough. But i do it simple by setting the Different title of ActionBar or ToolBar for Fragment. then onBackPress you just have to check the title and do whatever you want to do on that back press. You need proper code??? – akhil batlawala Sep 19 '15 at 13:10
  • Fragment 1 and Fragment 2 in use extends Fragment. – Parth Kathiriya Sep 19 '15 at 13:57

1 Answers1

0

FragmentManager has methods popBackStack() and popBackStackImmediate().

kris larson
  • 30,387
  • 5
  • 62
  • 74