How to close the current fragment by using Button like the back button?

I changed the code from

getActivity().getFragmentManager().beginTransaction().remove(this).commit();

to

getActivity().getFragmentManager().popBackStack();

And it pops out the top fragment

Leave a Comment