• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Switch between checkbox and radio button dynamically

andypaul1

Lurker
Dec 24, 2012
7
0
I have a created a custom listview. The contents of this view are updated dynamically. I have got the basic functionality working but here is one problem that I am unable to figure out.

Depending on business logic, my listview must be able to switch between single selection mode or multiple selection mode. So for example, in certain cases, the user must be able to select only one option (i.e. he must see a Radio button on the left) and in other cases, the user must be able to select multiple options (i.e. he must see a Checkbox on the left).

I have tried multiple things such as:
1. use a checkbox (with no text), a radiobutton(with no text) and a textview (for displaying the option text). Hide the checkbox or the radio button depending on whether it is single selection mode or multiple. The problem is the radio button functionality doesn't work. i.e even after using RadioGroup, the user is able to select multiple items.
Also, this seems to be an ugly hack or a solution.

2. use a CheckBox . In this case, even when i set the single_choice mode on the listview, I don't get radiobutton.

3. Use CheckedTextView. In this case, I am unable to customize the look to get the checkbox or radio button on the left. Also, I don't get the radio button.

So I am not sure now what to do? Will appreciate any pointer.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones