Recyclerview changing items when is scrolled

后端 未结 6 786
一个人的身影
一个人的身影 2021-02-09 17:57

Can someone explain to me, what the problem is?

When I scroll down and then back to the top, my items were changed for other items in the list, and if I scroll again, th

6条回答
  •  悲哀的现实
    2021-02-09 18:28

    Recyclerview shuffling issue understanding of the concept behind

      @Override
      public void onBindViewHolder(final MyViewHolder holder, int position) {
          holder.setIsRecyclable(false);
      }
    
     @Override
     public long getItemId(int position) 
     {
            return position;
     }
    
     @Override
     public int getItemViewType(int position) 
     {
            return position;
     }
    

    Add setHasStableIds(true); in your adapter constructor and Override these two methodes in adapter.

提交回复
热议问题