//首先创建接口 用于传送下标
package com.example.mr.zongheyemian; import android.view.View; /** * Created by Mr赵 on 2017/12/10. */ public interface jiekou { void onclick(int postion); }
//在Adapter适配器中创建点击事件--向接口发送一个下标
if (jie != null) { holder.view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { jie.onclick(position); } }); }public void getthis(jiekou jie){ this.jie=jie; }在Activity中实现接口重写方法neiAdapter.getthis(NeirongActivity.this);@Override public void onclick(int postion) { Intent intent = new Intent(NeirongActivity.this,XiangqingActivity.class); intent.putExtra("url",data.get(postion).getDetailUrl()); startActivity(intent); }