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
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 92f3ffc..a041a46 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -456,13 +456,20 @@
     }
 
     /**
-     * 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 @@
     /**
      * 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.
      */