In your adapter class override these two methods
@Override
public int getViewTypeCount() {
return getCount();
}
@Override
public int getItemViewType(int position) {
return position;
}
Note: For recyclerview just method getItemViewType(int position)
will work.