Tuesday, 15 April 2014

alert dailog in android

following is simple code of alert dailog builder

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);

// set title
alertDialogBuilder.setTitle("select video quality");

        alertDialogBuilder
.setMessage("play low quality video if your using 2g and high quality if your using 3g or wifi")
.setCancelable(true)
.setPositiveButton("first",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
//ur code when first button is clicked
}
  })
.setNegativeButton("second",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
//wehn second alert dailogue is clicked
}
});

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();

// show it

alertDialog.show();

6 comments: