RecyclerView onclick
RecyclerView step 3
step1
public class xxxxxxxx extends RecyclerView.Adapter<MyAdapter.ViewHolder> implements View.OnClickListener {
step2
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position
viewHolder.textView.setOnClickListener(this);
textView is findViewById(R.id.xxxxxxxxx)
step3
@Override
public void onClick(View view) {
int viewId = view.getId();
if (viewId == R.id.xxxxxxxxx) { //which item click
if (onItemClickListener != null) {
onItemClickListener.onItemClick(view, (Integer) view.getTag());
}
}
}
view.getTag() maybe null