how to highlight the selected Item of Recycler View?

前端 未结 8 1330
执念已碎
执念已碎 2020-11-28 03:02

I have a Recycler View with the Images loaded from the Internal Storage. I want to Highlight the selected item when clicked. I tried a lot of thing but it was not working. A

8条回答
  •  孤街浪徒
    2020-11-28 03:37

    you can use this code out of Adapter

    LinearLayoutManager RvLayoutManager = (LinearLayoutManager)rootlayout.getLayoutManager();
    View itemSelected = RvLayoutManager.findViewByPosition(position);
    itemSelected.setBackgroundColor(Color.Red);
    

提交回复
热议问题