[转] How to prevent items from getting duplicated when scrolling recycler view

Original address: http://stackoverflow.com/questions/33316837/how-to-prevent-items-from-getting-duplicated-when-scrolling-recycler-view

RecyclerView data shows duplicate problems. (Solutions such as ListView are similar)
After searching on the Internet for a long time, I found that the modification methods are too troublesome, and some of them are relatively copycats. I think there should be a very simple modification method for this problem, so after various searches, I finally found a more serious and simple modification method:

just overwrite the following method in the Adapter:
@Override
public long getItemId(int position) {
    return position;
}
@Override
public int getItemViewType(int position) {
   return position;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326398081&siteId=291194637