Reputation: 425
I want to when button clicked to return to previous fragment. This is how I create fragment:
getActivity().getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, statisticsSpecificStudentFragment)
.addToBackStack("StatisticsStudentOverallFragment")
.commit();
This is how I try and return to this fragment, from whom I started new fragment:
btDone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().getSupportFragmentManager().popBackStack();
}
});
All that happends is that it reloads current fragment, like I added current one to stack but I did not.
Upvotes: 0
Views: 424
Reputation: 469
Try
popBackStack("StatisticsStudentOverallFragment")
Or
addToBackStack(null)
and keep popBackStack() like you have it already.
Upvotes: 1