简体   繁体   English

Recycler view select position border will appear and not selected border not appear - how to make design in Android Studio like highlight position 8817734731788

[英]Recycler view select position border will appear and not selected border not appear - how to make design in Android Studio like highlight position

Recycler view select position border will appear and not selected border not appear. Recycler view select position 边框会出现,未选中的边框不会出现。 How to make design in Android Studio like highlight position. See my image: How to make design in Android Studio like highlight position.看我的图片:

图片

Suppose you want to display list of object. eg list of this model class data class User(val name:String, val age:Int, var isSelected:Boolean)假设您要显示 object 的列表。例如,列表 model class data class User(val name:String, val age:Int, var isSelected:Boolean)
You can see that I have added isSelected:Boolean in Model class. You can pass true for the item which you want to keep selected and false for other items.你可以看到我在Model class中添加了isSelected:Boolean 。你可以为你想要保持选中的项目传递true,为其他项目传递false。 When you are done with that you need to add if/else case in adapter in your onBindViewHolder完成后,您需要在onBindViewHolder的适配器中添加 if/else case

if(isSelected){
// change you UI for that item selected here
}else {
// change you UI for that items not selected here
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM