Start a new Activity from Fragment

前端 未结 7 2062
遇见更好的自我
遇见更好的自我 2020-12-05 08:09

Using Android Studio, I have my MainActiviy class with a Placeholder fragment. This fragment has buttons, but one has to load an Activity. How does one do this? I was tol

7条回答
  •  囚心锁ツ
    2020-12-05 08:23

    For fragment you have to use getactivity().... For Example:

    Intent intent = new Intent(getActivity(), AnotherActivity.class);
    startActivity(intent);
    

提交回复
热议问题