如何在android中的recycler视图中显示第一项的选择?
I have implemented the recycler view in navigation drawer in android.This is working fine.I am able to switch between item by clicking on recycler view item. but i am not able to change the background color for the selected item.please suggest me how to imeplement it.I have tried this so far.
我在android中的导航抽屉中实现了回收器视图。这样工作正常。我可以通过单击回收器视图项来切换项目。但是我无法改变所选项目的背景颜色。请告诉我如何改进它。到目前为止我已经尝试过了。
1.Background Selector in RecyclerView Item Tried to make recycler view clickable,focusable but didn't work
1. RecyclerView项目中的背景选择器试图使回收者视图可点击,可聚焦但不起作用
2.http://innodroid.com/blog/post/tracking-selected-item-in-recyclerview
implemented but didn't understand where to write the code for changing background
实现但不明白在哪里编写代码来改变背景
Please help me out.
请帮帮我。
2 个解决方案
#1
Recycler view are recommend when you have very large items & wants to have a custom UI. If you want to display only few items the would recommend to use List View.
如果您有非常大的商品并希望拥有自定义UI,则建议使用Recycler视图。如果您只想显示几个项目,建议使用列表视图。