Cannot resolve method startActivity()

后端 未结 4 712
天命终不由人
天命终不由人 2021-02-07 09:08

I\'m new to the android development and having a bit of a problem changing activities. I am trying to change activities from within a method but I am getting the error can

4条回答
  •  一生所求
    2021-02-07 09:57

    To start a new activity you will need a context to start from, and your current activity "BaseAdapter" is not a Context, luckly every view has a Context, so you can do like this:

    public void open301(View view) {
        Intent openThree = new Intent(view.getContext(), ThreeZeroOne.class);
        view.getContext().startActivity(openThree);
    }
    

提交回复
热议问题