Display alert dialog on Android mobile

Activity Forums Android mobile app Display alert dialog on Android mobile

  • This topic is empty.
  • Creator
    Topic
  • #121
    adcocitclass
    Keymaster

    AlertDialog.Builder is used To display alert dialog with OK/Cancel button. We need to use alert builder as shown below. Following is example code,


    new AlertDialog.Builder(context)
    .setTitle("Delete entry")
    .setMessage("Are you sure you want to delete this entry?")
    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    // continue with delete
    }
    })
    .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    // do nothing
    }
    })
    .setIcon(android.R.drawable.ic_dialog_alert)
    .show();

  • You must be logged in to reply to this topic.