ask via AlertDialog - Android User Interface

Android examples for User Interface:Alert Dialog

Description

ask via AlertDialog

Demo Code


//package com.java2s;

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

public class Main {
    static public void askAlert(Context ctx, final String message,
            String title, DialogInterface.OnClickListener ok) {
        AlertDialog.Builder builder = new AlertDialog.Builder(ctx);

        builder.setTitle(title);/*from   w ww.  j ava  2 s . c o m*/
        builder.setMessage(message);

        builder.setPositiveButton("YES", ok);

        builder.setNegativeButton("NO",
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing
                        dialog.dismiss();
                    }
                });

        AlertDialog alert = builder.create();
        alert.show();
    }
}

Related Tutorials