Android AlertDialog Create showAlert(Context context, String title, String message)

Here you can find the source of showAlert(Context context, String title, String message)

Description

show Alert

License

Open Source License

Parameter

Parameter Description
context a parameter
title a parameter
message a parameter

Declaration

public static void showAlert(Context context, String title,
        String message) 

Method Source Code

//package com.java2s;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Main {
    /**/*from w  ww  .  java  2  s  . c o m*/
     * 
     * @param context
     * @param title
     * @param message
     */
    public static void showAlert(Context context, String title,
            String message) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                context);
        alertDialogBuilder
                .setTitle(title)
                .setMessage(message)
                .setCancelable(false)
                .setNeutralButton("OK",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                // if this button is clicked, close
                                // current activity
                                dialog.dismiss();
                            }
                        });

        AlertDialog alertDialog = alertDialogBuilder.create();

        // show it
        alertDialog.show();
    }
}

Related

  1. confirm(String title, View view, Context context, DialogInterface.OnClickListener onConfirmListener)
  2. confirmBuilder(String title, Context context, DialogInterface.OnClickListener onConfirmListener)
  3. canShowAlertDialog(Context context)
  4. buildAlertMessageNoGps(final Context context)
  5. alert(Context ctx, String msg)
  6. showAlertDialog(Context context, String title, String message)
  7. manageAlertDialog( final Activity fourerrActivity, final String dialogTitle, final String dialogMessage)
  8. showAlertDialog(Context context, String title, String message, String btnString, DialogInterface.OnClickListener onClickListener)
  9. newYesNoDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId, OnClickListener listener)