瀏覽代碼

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

Aidan Follestad 10 年之前
父節點
當前提交
2502938b03
共有 2 個文件被更改,包括 25 次插入3 次删除
  1. 8 3
      README.md
  2. 17 0
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 8 - 3
README.md

@@ -278,11 +278,16 @@ dialog.setActionButton(DialogAction.NEGATIVE, "New Title");
 If you want to forcefully hide the action buttons:
 If you want to forcefully hide the action buttons:
 
 
 ```java
 ```java
-new MaterialDialog.Builder(this)
+MaterialDialog dialog new MaterialDialog.Builder(this)
         // ... other initialization
         // ... other initialization
         .hideActions()
         .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));
         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.
      * Retrieves the custom view that was inflated or set to the MaterialDialog during building.
      */
      */