I\'m using RecyclerView
with CardView
and inside the CardView
have 2 buttons. Now, have implemented the onClick
events by imp
Try this
In your activity do like this
CustomItemClickListener listner;
listner=YourActivityName.this // in OnCreate Method
and pass this listner in your adapter
adapter = new ItemsListAdapter(getActivity(), data, listner);
And in your Adapter use it like this
CustomItemClickListener listner;
this.listner=listner; // In your Adapter COnstructor
and last in your onBindViewHolder do like this
holder.button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listner.onItemClick(holder.getLayoutPosition()); //getting position
}
});
holder.button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listner.onItemClick(holder.getLayoutPosition()); //getting position
}
});