You can use Alertdialog.builder to generate a prompt box
The simplest thing to do is pop up a message box :
New Alertdialog.builder (self). Settitle ("title"). Setmessage ("Simple message box") . Setpositivebutton ("OK", null). Show ();
The effect is as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/49/E8/wKiom1Qe4lHAXmZlAABWNVK03qE016.jpg "title=" Cheetah 20140921223514.png "alt=" Wkiom1qe4lhaxmzlaabwnvk03qe016.jpg "/>
dialog box with confirmation and Cancel buttons:
New Alertdialog.builder (self). Settitle ("yes"). Setmessage ("Yes? "). Setpositivebutton (" yes ", null). Setnegativebutton (" No ", null). Show ();
dialog boxes where you can enter text:
New Alertdialog.builder (self). Settitle ("Please enter text:"). SetIcon (Android. R.drawable.ic_dialog_info). Setview (new EditText (self)). Setpositivebutton ("OK", null). Setnegativebutton ("Cancel", null ). Show ();
Radio Box:
new alertdialog.builder (self) .settitle ("Please select:") .seticon (Android. R.drawable.ic_dialog_info) .setsinglechoiceitems (new string[] {"option 1", "Option 2", "option 3", "Option 4"}, 0, new dialoginterface.onclicklistener () { public void onclick ( Dialoginterface dialog, int which) { dialog.dismiss (); } } ) .setnegativebutton ("Cancel", null) .show ();
Multi Box:
New Alertdialog.builder (self). Settitle ("Multi Box"). Setmultichoiceitems (new string[] {"Option 1", "Option 2", "option 3", "Option 4"}, NULL, NULL). Setpositivebutton ("OK", null). Setnegativebutton ("Cancel", null). Show ();
List dialog box:
New Alertdialog.builder (self). Settitle ("list box"). Setitems (new string[] {"List item 1", "List item 2", "List Item 3"}, NULL). Setnegativebutton ("OK", null). Show ();
To display a picture in a dialog box:
ImageView img = new ImageView (self); Img.setimageresource (R.drawable.icon); New Alertdialog.builder (self). Settitle ("picture box"). Setview (IMG). Setpositivebutton ("OK", null). Show ();
Event handling:
With a definite dialog box
New alertdialog.builder (This) .setmessage ("This is the second hint") .setpositivebutton ("OK", new dialoginterface.onclicklistener () { public void onclick (dialoginterface dialoginterface, Int i) { //Button Event } }) .show ();
dialog box with OK and cancel
New alertdialog.builder (This) .settitle ("hint") .setmessage ("OK exit?") .seticon (r.drawable.quit) .setpositivebutton ("OK", new dialoginterface.onclicklistener () { public void onclick (dialoginterface dialog, int Whichbutton) { setresult (RESULT_OK);//OK button event finish (); } }) .setnegativebutton ("Cancel", new dialoginterface.onclicklistener () { public void onclick (Dialoginterface dialog, int whichbutton) &NBsp { //Cancel button event } }) .show ();
This article is from the "Zifangsky" blog, make sure to keep this source http://983836259.blog.51cto.com/7311475/1556770
Android generates a prompt box