summaryrefslogtreecommitdiff
path: root/core/java/android/app/Dialog.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2013-12-05 11:10:31 -0800
committerAlan Viverette <alanv@google.com>2013-12-05 11:10:31 -0800
commitec186706df72fbb62bfe813d83cff9167dd95cb4 (patch)
tree14f2e123fdf18347cf6447c2d6641a49421a4268 /core/java/android/app/Dialog.java
parentfa706a88a3a2cf3e18229fa2d4cc93ac63d2afef (diff)
Allow alert dialogs to inflate custom view layouts
Adds APIs to set a layout resource ID as an AlertDialog's custom view. To make this useful for developers, also ensures that Dialog content is set up when calls are made to Dialog.findViewById() before show(). BUG: 11136748 Change-Id: I29747a28d7e30f4e31fe474424109ff29e1eaa98
Diffstat (limited to 'core/java/android/app/Dialog.java')
-rw-r--r--core/java/android/app/Dialog.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 92f3ffcfc963..a041a46f8b91 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -456,13 +456,20 @@ public class Dialog implements DialogInterface, Window.Callback,
}
/**
- * Finds a view that was identified by the id attribute from the XML that
- * was processed in {@link #onStart}.
+ * Finds a child view with the given identifier.
+ * <p>
+ * Prior to API 20, this function could only be used after the first call
+ * to {@link #show()}. In later versions, this function may be used at any
+ * time; however, the first call to this function "locks in" certain dialog
+ * characteristics.
*
* @param id the identifier of the view to find
- * @return The view if found or null otherwise.
+ * @return The view with the given id or null.
*/
public View findViewById(int id) {
+ if (!mCreated) {
+ dispatchOnCreate(null);
+ }
return mWindow.findViewById(id);
}
@@ -479,7 +486,7 @@ public class Dialog implements DialogInterface, Window.Callback,
/**
* Set the screen content to an explicit view. This view is placed
* directly into the screen's view hierarchy. It can itself be a complex
- * view hierarhcy.
+ * view hierarchy.
*
* @param view The desired content to display.
*/