confirm alert dialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

confirm alert dialog

Demo Code


//package com.java2s;

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

public class Main {
    public static void confirm(Context context, String title,
            String content, OnClickListener ok_callback,
            OnClickListener no_callback) {
        Builder myAlertDialog = new AlertDialog.Builder(context);
        myAlertDialog.setIcon(android.R.drawable.ic_dialog_alert);
        myAlertDialog.setTitle(title);//from www. j  av a2  s.co m
        myAlertDialog.setMessage(content);

        DialogInterface.OnClickListener empty = new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

            }
        };
        if (ok_callback == null) {
            ok_callback = empty;
        }
        if (no_callback == null) {
            no_callback = empty;
        }
        myAlertDialog.setNegativeButton("?T?w", ok_callback);
        myAlertDialog.setPositiveButton("????", no_callback);
        myAlertDialog.show();

    }
}

Related Tutorials