-1

I had a problem: when i clicked a checkbox of single item in recycler view, other item's checkboxes also got selected....But when i overided these two methods and returen position with it,problem was solved.... So my question is how did they solve my problem???

Already know what is written in android documentation.

@Override
public long getItemId(int position) {
    return position;
}

@Override
public int getItemViewType(int position) {
    return position;
}
Dharmik Thakkar
  • 1,650
  • 1
  • 9
  • 18

1 Answers1

1

getItemViewType() is mainly used when you want show different types of view based on your position .

Let say you have a chat adapter , sender user chat should comes in right while receiver user chat should comes in left . In such scenrio , you can use getItemViewType (based of user id , you can show the different views)

getItemId() : We usually use this , when we try to do specific task for particular item . For getItemId you may check this . What is the intent of the methods getItem and getItemId in the Android class BaseAdapter?

Mini Chip
  • 949
  • 10
  • 12