Background color or Images shuffling on scrolling in recyclerview?

后端 未结 3 601
鱼传尺愫
鱼传尺愫 2020-12-11 07:39

I am wondering that my images and color of layouts shuffling when i scrolls downwards or upwards, I created cardview using recyclerview. and set an image(changes color on cl

3条回答
  •  情书的邮戳
    2020-12-11 08:22

    In my case overriding getItemId and setting sethasStableIds to true solved the shuffling issue.

    in adapter:

        @Override
        public long getItemId(int position) {
        Object listItem = feeds.get(position);
        return listItem.hashCode();
        }
    

    in main activity/fragment :

        adapter = new FeedAdapter(feeds, getContext());
        adapter.setHasStableIds(true);
    

提交回复
热议问题