Finishing current activity from a fragment

前端 未结 11 1514
野的像风
野的像风 2020-12-13 02:02

I have a fragment in an activity that I am using as a navigation drawer. It contains buttons that when clicked start new activities (startActivity from a fragment simply ca

11条回答
  •  时光取名叫无心
    2020-12-13 02:27

    Very simple...

    1- just grab activity by getActivity() in the fragment

    2- then call finish();

    So just getActivity().finish(); will finish the parent activity.

提交回复
热议问题