How to start Activity in adapter?

前端 未结 8 1264
执念已碎
执念已碎 2020-11-27 03:16

I have a ListActivity with my customized adapter and inside each of the view, it may have some buttons, in which I need to implement OnClickListener. I need to

8条回答
  •  失恋的感觉
    2020-11-27 03:29

    When implementing the onClickListener, you can use v.getContext.startActivity.

    btn.setOnClickListener(new OnClickListener() {                  
        @Override
        public void onClick(View v) {
            v.getContext().startActivity(PUT_YOUR_INTENT_HERE);
        }
    });
    

提交回复
热议问题