Recyclerview scrolling messes the UI items

1) If you are using ListView – override the following methods.

    @Override
    public int getViewTypeCount() {

        return getCount();
    }

    @Override
    public int getItemViewType(int position) {

        return position;
    }

2) If you are using RecyclerView – override only getItemViewType method.

    @Override
    public int getItemViewType(int position) {

        return position;
    }

it seems that for the recycler view by just overriding the getItemViewType() solves this issue, no need to manually keep track of the state

 

source: android how to sort an arraylist

Leave a Reply

Your email address will not be published. Required fields are marked *