瀏覽代碼

Fix for single/multi choice selection callback getting wrong index.

Aidan Follestad 10 年之前
父節點
當前提交
6deb1a6f12
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 3 - 3
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -377,7 +377,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
                     @SuppressLint("WrongViewCast")
                     RadioButton rb = (RadioButton) itemView.findViewById(R.id.control);
                     if (rb.isChecked()) {
-                        listCallbackSingle.onSelection(this, v, i, ((TextView) itemView.findViewById(R.id.title)).getText().toString());
+                        listCallbackSingle.onSelection(this, v, i - 1, ((TextView) itemView.findViewById(R.id.title)).getText().toString());
                         break;
                     }
                 }
@@ -390,7 +390,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
                     View itemView = list.getChildAt(i);
                     CheckBox rb = (CheckBox) itemView.findViewById(R.id.control);
                     if (rb.isChecked()) {
-                        selectedIndices.add(i);
+                        selectedIndices.add(i - 1);
                         selectedTitles.add(((TextView) itemView.findViewById(R.id.title)).getText().toString());
                     }
                 }
@@ -804,4 +804,4 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
     public static interface FullCallback extends Callback {
         void onNeutral(MaterialDialog dialog);
     }
-}
+}