Skip to content

Instantly share code, notes, and snippets.

@javikin
Created December 1, 2017 01:11
Show Gist options
  • Save javikin/dc661fe252a5fb6ca5b0fcb2be618f45 to your computer and use it in GitHub Desktop.
Save javikin/dc661fe252a5fb6ca5b0fcb2be618f45 to your computer and use it in GitHub Desktop.
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
...
private CallBackItemList mListener;
public MyAdapter(String[] myDataset, CallBackItemList listener) {
...
mListener = listener;
}
...
public interface CallBackItemList {
void onClickActionItemList();
void onClickActionButtonItemList();
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mListener.onClickActionItemList();
}
});
holder.mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mListener.onClickActionButtonItemList();
}
});
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment