show Alert Dialog using - Android User Interface

Android examples for User Interface:Alert Dialog

Description

show Alert Dialog using

Demo Code


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

public class Main{
    public static void showAlertDialog(final Context context,
            final int titleId, final String message) {
        new AlertDialog.Builder(context)
                .setTitle(titleId)//from w  w  w  .j  av a2 s . co m
                .setMessage(message)
                .setNegativeButton(android.R.string.ok,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                dialog.dismiss();
                            }
                        }).show();
    }
}

Related Tutorials