Move RecyclerView clicked item to the top

后端 未结 2 1402
情歌与酒
情歌与酒 2021-01-14 09:35

I have a recyclerView with n items. Each item is expandable onCLick of it. I want my item to expand as well as move to the top onCLick. Suppose if I click third item then it

相关标签:
2条回答
  • You can do like this way: Create one method in adaptor as below.

     public void swapeItem(int fromPosition,int toPosition){
         Collections.swap(arrayList, fromPosition, toPosition);
         notifyItemMoved(fromPosition, toPosition);
     }
    

    now on item click you can use like this way.

    swapeItem(9,0); // here 9 is a clicked item position and 0 means at top of the list.
    
    0 讨论(0)
  • 2021-01-14 09:52

    Moving to the top? Sure!

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