Aidan Follestad 10 anni fa
parent
commit
18ade76f55

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

@@ -39,6 +39,8 @@ import java.util.List;
 public class MaterialDialog extends DialogBase implements View.OnClickListener, MeasureCallbackScrollView.Callback {
 
     private Activity mContext;
+    private TextView title;
+
     private CharSequence positiveText;
     private TextView positiveButton;
     private CharSequence neutralText;
@@ -97,7 +99,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         this.autoDismiss = builder.autoDismiss;
 
 
-        TextView title = (TextView) view.findViewById(R.id.title);
+        title = (TextView) view.findViewById(R.id.title);
         final TextView content = (TextView) view.findViewById(R.id.content);
 
         content.setText(builder.content);
@@ -886,6 +888,22 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         setActionButton(which, mContext.getString(titleRes));
     }
 
+    /**
+     * Updates the dialog's title.
+     */
+    public final void setTitle(CharSequence title) {
+        this.title.setText(title);
+    }
+
+    public final void setContent(CharSequence content) {
+        ((TextView) view.findViewById(R.id.content)).setText(content);
+    }
+
+    public final void setItems(String[] items) {
+        this.items = items;
+        invalidateList();
+    }
+
     /**
      * Hides the positive/neutral/negative action buttons.
      */

+ 2 - 10
library/src/main/java/com/afollestad/materialdialogs/base/DialogBase.java

@@ -71,19 +71,11 @@ public class DialogBase extends AlertDialog implements DialogInterface.OnShowLis
     }
 
     /**
-     * @deprecated Not supported by the Material dialog.
+     * @deprecated Use setContent() instead.
      */
     @Override
     public void setMessage(CharSequence message) {
-        throw new RuntimeException("This method is not supported by the MaterialDialog.");
-    }
-
-    /**
-     * @deprecated Not supported by the Material dialog.
-     */
-    @Override
-    public void setTitle(CharSequence title) {
-        throw new RuntimeException("This method is not supported by the MaterialDialog.");
+        throw new RuntimeException("This method is not supported by the MaterialDialog, use setContent() instead.");
     }
 
     /**