Start a new Activity from Fragment

前端 未结 7 2019
遇见更好的自我
遇见更好的自我 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:43

    If you have to use it inside onBindViewHolder, you may do this:

    @Override
    public void onClick(View view) {
        Intent intent= new Intent(view.getContext(), MainActivity.class);
        view.getContext().startActivity(intent);
    }
    

提交回复
热议问题