Browse Source

Fixed issues with radio buttons in single choice lists, should fix https://github.com/afollestad/material-dialogs/issues/790

Aidan Follestad 9 years ago
parent
commit
c75f3830de

+ 0 - 4
core/src/main/java/com/afollestad/materialdialogs/DefaultAdapter.java

@@ -25,8 +25,6 @@ class DefaultAdapter extends BaseAdapter {
     private final int layout;
 
     private final GravityEnum itemGravity;
-    public RadioButton mRadioButton;
-    public boolean mInitRadio;
 
     public DefaultAdapter(MaterialDialog dialog, @LayoutRes int layout) {
         this.dialog = dialog;
@@ -68,8 +66,6 @@ class DefaultAdapter extends BaseAdapter {
                 boolean selected = dialog.mBuilder.selectedIndex == index;
                 MDTintHelper.setTint(radio, dialog.mBuilder.widgetColor);
                 radio.setChecked(selected);
-                if (selected && mInitRadio)
-                    mRadioButton = radio;
                 break;
             }
             case MULTI: {

+ 2 - 10
core/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -226,18 +226,10 @@ public class MaterialDialog extends DialogBase implements
                     mBuilder.selectedIndex = oldSelected;
                 }
                 // Update the checked states
-                if (allowSelection && mBuilder.selectedIndex != position) {
+                if (allowSelection) {
                     mBuilder.selectedIndex = position;
-                    // Uncheck the previously selected radio button
-                    if (adapter.mRadioButton == null) {
-                        adapter.mInitRadio = true;
-                        adapter.notifyDataSetChanged();
-                    }
-                    if (adapter.mRadioButton != null)
-                        adapter.mRadioButton.setChecked(false);
-                    // Check the newly selected radio button
                     radio.setChecked(true);
-                    adapter.mRadioButton = radio;
+                    adapter.notifyDataSetChanged();
                 }
             }
 

+ 1 - 0
core/src/main/res/layout-ldrtl/md_listitem_multichoice.xml

@@ -28,6 +28,7 @@
         android:id="@+id/control"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
+        android:button="@drawable/abc_btn_check_material"
         android:clickable="false"
         android:focusable="false"
         android:focusableInTouchMode="false"

+ 1 - 0
core/src/main/res/layout-ldrtl/md_listitem_singlechoice.xml

@@ -28,6 +28,7 @@
         android:id="@+id/control"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
+        android:button="@drawable/abc_btn_radio_material"
         android:clickable="false"
         android:focusable="false"
         android:focusableInTouchMode="false"

+ 1 - 0
core/src/main/res/layout/md_listitem_multichoice.xml

@@ -16,6 +16,7 @@
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:clickable="false"
+        android:button="@drawable/abc_btn_check_material"
         android:focusable="false"
         android:focusableInTouchMode="false"
         android:gravity="center_vertical" />

+ 1 - 0
core/src/main/res/layout/md_listitem_singlechoice.xml

@@ -15,6 +15,7 @@
         android:id="@+id/control"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
+        android:button="@drawable/abc_btn_radio_material"
         android:clickable="false"
         android:focusable="false"
         android:focusableInTouchMode="false"