Show Confirm Alert Dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

Show Confirm Alert Dialog

Demo Code


//package com.java2s;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Main {
    public static void ShowConfirmAlert(Context context, String heading,
            String description, DialogInterface.OnClickListener action) {
        new AlertDialog.Builder(context)
                .setTitle(heading)/*w ww  .  j  av  a  2s .co  m*/
                .setMessage(description)
                .setPositiveButton(android.R.string.yes, action)
                .setNegativeButton(android.R.string.no,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                // do nothing
                            }
                        }).setIcon(android.R.drawable.ic_dialog_info)
                .show();
    }
}

Related Tutorials