how to call Activity class from Fragment

前端 未结 1 1633
我寻月下人不归
我寻月下人不归 2021-01-16 07:19

I am working with Navigation Drawer and i want to call testActivity.java class when someone click on a item that is in the sliding menu.Currently my MainActivity.java calss

相关标签:
1条回答
  • 2021-01-16 08:13

    In fragment you can access its parent FragmentActivity instance using getActivity(). And since that instance is an activity, so using that you can call another activity simply.

    Intent myIntent = new Intent((ParentActivity)getActivity(), YourOtherActivity.class);
    (ParentActivity)getActivity().startActivity(myIntent); 
    
    0 讨论(0)
提交回复
热议问题