0

I am using 7 radio buttons which correspond to days of the week. I am not putting them in a radio group because a user should be able to select multiple days/buttons. However, once the button is checked, it is permanently checked and I don't know why. First off, should I even be using radio buttons for this?

Here is my xml code:

<RadioButton
    android:id="@+id/tuesday_radioButton"
    android:button="@null"
    android:layout_width="45dp"
    android:layout_height="45dp"
    android:text="T"
    android:gravity="center"
    style="@style/circleButton_style"
    />

Corresponding style code:

<style name="circleButton_style" parent="AppTheme">
    <item name="android:background">@drawable/circle_stand_sel</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:minHeight">48dp</item>
    <item name="android:paddingLeft">5dp</item>
    <item name="android:paddingRight">5dp</item>
    <item name="android:button">@null</item>
</style>

And my drawable:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/circle_pressed"
        android:state_checked="true"/>

    <item android:drawable="@drawable/circle"
        android:state_checked="false"/>

    <item android:drawable="@drawable/circle"/>

</selector>
ekad
  • 14,436
  • 26
  • 44
  • 46
  • 2
    Radio buttons should be used when a *single* option can be chosen at a time. Check boxes should be used when multiple options at a time are possible. – Dan Harms Jul 10 '15 at 18:39
  • `a user should be able to select multiple days`. Don't use radio buttons, then. – njzk2 Jul 10 '15 at 21:07

1 Answers1

0

Put all RadioButtons in a single Radiogroup then only it will work

http://examples.javacodegeeks.com/android/core/ui/radiogroup/android-radiogroup-example/

Can i know what is the purpose you want to achieve

If you want multiple selection you have to use checkboxes with its button style

Nilay Dani
  • 896
  • 6
  • 24