Set a custom view to be the contents of the Dialog.
Parameters: view - The view to use as the contents of the Dialog.
Returns: This Builder object to allow for chaining of calls to set methods
1. Create an AlertDialog with Supplied Arguments named myAlertDialogBuilder.
2. In the showAlertDialog method, instantiate the object(s) you would like to add to the AlertDialog. In this example I will Instantiate a new EditText named myEditText, after the AlertDialog is instantiated. Other example items you might instantiate are an ImageView, CheckBox,or a LinearLayout to include many widgets.
3. Add the below line to add the EditText to the AlertDialog. This example below will add the EditText myEditText to the Alertdialog named myAlertDialogBuilder.
myAlertDialogBuilder.setView(myEditText);
3. Add the below line to add the EditText to the AlertDialog. This example below will add the EditText myEditText to the Alertdialog named myAlertDialogBuilder.
myAlertDialogBuilder.setView(myEditText);
4. Compile and run!
Soft keyboard pop-ups when user presses EditText |
Resources:
http://developer.android.com/reference/android/app/AlertDialog.Builder.html#setView(android.view.View)
http://www.codeofaninja.com/2011/07/android-alertdialog-example.html