Question

I need to have a single radiobutton that I can check and uncheck.

But from my readings on stack overflow, the radio button will stay checked once it is checked as on option needs to be selected?

Here is my code so far:

            RadioButton rButton = new RadioButton(getActivity());
            rButton.setText(listItems.get(i));
            rButton.setId(i);
            rButton.setChecked(false);
            rButton.setClickable(true);
            // rButton.setOnClickListener(new View.OnClickListener() {
            // @Override
            // public void onClick(View v) {
            // RadioButton rButton = (RadioButton)
            // layout.findViewById(position);
            // rButton.setChecked(!rButton.isChecked());
            // }
            // });              
            layout.addView(rButton);

it does work even with the commented out onclick listener.

How can i get the radio button to uncheck?

Was it helpful?

Solution

I think you need a CheckBox Instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top