Aidan Follestad 10 년 전
부모
커밋
5266a32bdc
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 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();