Android RecyclerView Adapter: notifyItemInserted and notifyItemMoved at index 0 not working

前端 未结 2 808
栀梦
栀梦 2021-01-17 16:33

I have a RecyclerView with a horizontal linear layout manager declared like this:

RecyclerView graph = (RecyclerView) findViewById(R.id.graph);

RecyclerView         


        
相关标签:
2条回答
  • 2021-01-17 17:08

    I removed recycler.setHasFixedSize(true); and now it works. I have no idea why this would be related though.

    0 讨论(0)
  • 2021-01-17 17:22

    This may happen because of setting recycler.setHasStableIds(true) and then using item's position to assign the getItemId in the adapter.

    This will just update that one position and other items won't be shifted as they have should.

    0 讨论(0)
提交回复
热议问题