• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Kotlin : Single selection in RecyclerView

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my android app with Kotlin, i use a recycler view with item ImageButton
The description in the following Url :
webpage
the following code is my adapter :

I want to choose only single item(color) when click on which one.
like the following picture 1 and 2 not like the picture 3
1.png
[Thumbnail for 1.png]
2.png
[Thumbnail for 2.png]
3.png
[Thumbnail for 3.png]
 
Ranch Hand
Posts: 385
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need  radio button
 
Maha Sakka
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Randy Tong wrote:I think you need  radio button


you mean i use rasio button instead of  Image button ?
 
Randy Tong
Ranch Hand
Posts: 385
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create three radio buttons, and grouped in a radio group.
If radio buttons are in group, when one radio button within a group is selected, all others are automatically deselected.
 
Maha Sakka
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I change to radio button  as the following code:
         
and i add an adapter as the following code :

Still have the same error, and the background color is square shape not a cercle shape
 
Randy Tong
Ranch Hand
Posts: 385
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The radio button has all the effect you want, but unfortunately the color cannot be filled to the circle.

 
Maha Sakka
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use a recyclerview and adapter because the number and color are dynamic and not fixed
 
Randy Tong
Ranch Hand
Posts: 385
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please provide more code here,eg where to call ProductColorAdapter.
 
Maha Sakka
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the activity of product detail to get the color chosen after click on
 
Randy Tong
Ranch Hand
Posts: 385
4
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe upload your project to github, so we can test..?
 
Don't touch me. And dont' touch this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!