December 31st, 2012, 10:21 AM
Thread Author (OP)
Join Date: Dec 2012
Carrier: Not Provided
Thanked 0 Times in 0 Posts
Switch between checkbox and radio button dynamically
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.