rv的接口回调的点击事件

final MyViewHolder holder=new MyViewHolder(view);
view.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        int position = holder.getLayoutPosition();
        if (mlistener!=null){
            mlistener.OnItimeClick(position);
        }
    }
});




//点击事件
public interface OnItimeClickListener{
    void OnItimeClick(int position);
}
OnItimeClickListener mlistener;
public void setOnItimeClickListener(OnItimeClickListener onItimeClickListener){
    mlistener=onItimeClickListener;
}

你可能感兴趣的:(rv的接口回调的点击事件)