Aidan Follestad пре 10 година
родитељ
комит
5266a32bdc

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

@@ -1084,10 +1084,13 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
     }
 
     public final void setItems(CharSequence[] items) {
+        if (adapter == null)
+            throw new IllegalStateException("This MaterialDialog instance does not yet have an adapter set to it. You cannot use setItems().");
         if (adapter instanceof MaterialDialogAdapter) {
             adapter = new MaterialDialogAdapter(mContext, ListType.getLayoutForType(listType), R.id.title, items);
-        } else
+        } else {
             throw new IllegalStateException("When using a custom adapter, setItems() cannot be used. Set items through the adapter instead.");
+        }
         this.items = items;
         listView.setAdapter(adapter);
         invalidateCustomViewAssociations();