Why RecyclerView.notifyItemChanged() will create a new ViewHolder and use both the old ViewHolder and new one?

后端 未结 6 554
半阙折子戏
半阙折子戏 2020-12-18 17:57

Recently I use RecyclerView and add a custom header view (another type of item view) and try to updated it when data has changed. Something strange happens. The adapter crea

6条回答
  •  既然无缘
    2020-12-18 18:20

    More cleaner solution (is not bug in animator, but this is a feature of layout manager):

    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 5, LinearLayoutManager.VERTICAL, false){
            @Override
            public boolean supportsPredictiveItemAnimations() {
                return false;//super.supportsPredictiveItemAnimations();
            }
        });
    

提交回复
热议问题