I\'m using RecyclerView
with CardView
and inside the CardView
have 2 buttons. Now, have implemented the onClick
events by imp
I do it this way.
Set an OnClickListener on your Button in the ViewHolder
Create a method in your activity with the button position as a parameter
Pass the position of the clicked entry and do stuff
ViewHolder
yourButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
int position = getAdapterPosition(); //Clicked entry in your List
//Method from your activity
yourActivity.methodOnBtnClick(position);
}
Activity
public void methodOnBtnClick(int position)
{
yourList.remove(position);
recycler.getAdapter().notifyDataSetChanged();
}