Let's stop talking about it. Check the effect!
1 code
New AlertDialog. Builder (Lesson_01_Pic.this). setTitle ("prompt title"). setMessage ("this is the prompt content"). show ();
2 code
New AlertDialog. Builder (Lesson_01_Pic.this)
. SetTitle ("this is the title ")
. SetMessage ("this is the prompt content ")
. SetPositiveButton ("OK ",
New DialogInterface. OnClickListener (){
Public void onClick (DialogInterface dialoginterface, int I ){
// Button event
Toast. makeText (Lesson_01_Pic.this, "OK", Toast. LENGTH_LONG). show ();
}
}). Show ();
3 code
Import android. app. Activity;
Import android. app. AlertDialog;
Import android. app. Dialog;
Import android. content. DialogInterface;
Import android. content. DialogInterface. OnClickListener;
Import android. content. DialogInterface. OnMultiChoiceClickListener;
Import android. OS. Bundle;
Import android. view. View;
Import android. widget. Button;
Import android. widget. Toast;
Public class Lesson_02_Dia extends Activity {
/** Called when the activity is first created .*/
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
Button button = (Button) findViewById (R. id. b01 );
Button. setText ("dialog box ");
Button. setOnClickListener (new Button. OnClickListener (){
@ Override
Public void onClick (View v ){
// Option Array
String [] choices = {"Facebook", "Twitter "};
// Check the judgment array, which corresponds to the option
Boolean [] chsBool = {true, false };
// Dialog box containing multiple options and check boxes
AlertDialog dialog = new AlertDialog. Builder (Lesson_02_Dia.this)
. SetIcon (android. R. drawable. btn_star_big_on)
. SetTitle ("investigation ")
. SetMultiChoiceItems (choices, chsBool, multiClick)
. SetPositiveButton ("Yes", onclick)
. SetNegativeButton ("No", onclick). create ();
Dialog. show ();
}
});
}
/**
* Dialog box check box event listener
*/
OnMultiChoiceClickListener multiClick = new OnMultiChoiceClickListener (){
@ Override
Public void onClick (DialogInterface dialog, int which, boolean isChecked ){
Toast. makeText (Lesson_02_Dia.this, "nth" + (which + 1) + ", selected Result:" + isChecked, Toast. LENGTH_SHORT). show ();
}
};
/**
* Click Event listener in the dialog box.
*/
OnClickListener onclick = new OnClickListener (){
@ Override
Public void onClick (DialogInterface dialog, int which ){
Switch (which ){
Case Dialog. BUTTON_NEGATIVE:
Toast. makeText (Lesson_02_Dia.this, "No ..",
& Nbs