I'm using RecyclerView with CardView and inside the CardView have 2 buttons. Now, have implemented the onClick events by implementing View.OnClickListener by the ViewHolder static class and overriding the event (its working )like
@Override
public void onClick(View v) {
if (v.getId() == mClassBtn.getId()){
}
else if (v.getId() == mDaysBtn.getId()){
}
}
Looking for a solution/pattern to handle the Click in the Activity class like
adapter = new ItemsListAdapter(getActivity(), data, new CustomItemClickListener() {
@override
public void onItemClick(View v, int position) {
Log.d(TAG, "clicked position:" + position);
// which button clicked and separate action for each button
}
});
// CustomItemClickListener -- interface in the adapter class which holds the click event .
The above code working fine and able to log the Clicks but not able to differentiate which button has clicked.
Appreciate any help