Jelajahi Sumber

Added hideActions() option to the builder to force hide the action buttons.

Aidan Follestad 10 tahun lalu
induk
melakukan
2502938b03

+ 8 - 3
README.md

@@ -278,11 +278,16 @@ dialog.setActionButton(DialogAction.NEGATIVE, "New Title");
 If you want to forcefully hide the action buttons:
 
 ```java
-new MaterialDialog.Builder(this)
+MaterialDialog dialog new MaterialDialog.Builder(this)
         // ... other initialization
         .hideActions()
-        .build()
-        .show();
+        .build();
+dialog.show();
+
+// OR
+
+dialog.hideActions();
+dialog.showActions();
 ```
 
 --

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

@@ -758,6 +758,23 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         setActionButton(which, mContext.getString(titleRes));
     }
 
+    /**
+     * Hides the positive/neutral/negative action buttons.
+     */
+    public final void hideActions() {
+        hideActions = true;
+        invalidateActions();
+    }
+
+    /**
+     * Shows the positive/neutral/negative action buttons that were previously hidden.
+     */
+    public final void showActions() {
+        hideActions = false;
+        if (invalidateActions())
+            checkIfStackingNeeded();
+    }
+
     /**
      * Retrieves the custom view that was inflated or set to the MaterialDialog during building.
      */