Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static void createCancellableAcceptDialog(Context context, String title, String message,
            String acceptButtonText, final Runnable onAccept) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setInverseBackgroundForced(true);
        builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                if (onAccept != null)
                    onAccept.run();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}