I know there are no default selection methods in recyclerview class, But I have tried in following way,
public void onBindViewHolder(ViewHolder holder, final
I want to share the similar thing I have achieved, may be it will help someone.
below code is from the application to select an address from a list of addresses that are displayed in cardview(cvAddress)
, so that on click of particular item(cardview)
the imageView
inside the item should set to different resource(select/unselect)
@Override
public void onBindViewHolder(final AddressHolder holder, final int position)
{
holderList.add(holder);
holder.tvAddress.setText(addresses.get(position).getAddress());
holder.cvAddress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectCurrItem(position);
}
});
}
private void selectCurrItem(int position)
{
int size = holderList.size();
for(int i = 0; i
I don't know this is best solution or not but this worked for me.