How to start Activity in adapter?

前端 未结 8 1243
执念已碎
执念已碎 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:45

    If you want to redirect on url instead of activity from your adapter class then pass context of with startactivity.

    btnInstall.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse(link));
                    intent.setData(Uri.parse(link));
                    context.startActivity(intent);
                }
            });
    

提交回复
热议问题