Example usage for android.app AlertDialog.Builder setMessage

List of usage examples for android.app AlertDialog.Builder setMessage

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setMessage.

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:Main.java

public static AlertDialog AlertLog(Context ctx, String msg, String btn) {
    AlertDialog.Builder alertbox = new AlertDialog.Builder(ctx);
    alertbox.setMessage(msg);
    alertbox.setNegativeButton(btn, new DialogInterface.OnClickListener() {
        @Override/*from  w w  w  .j  a  v a2 s.co  m*/
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    return alertbox.create();
}

From source file:Main.java

public static AlertDialog.Builder creativeAlertDialog(Context context, String message) {
    AlertDialog.Builder alert = new AlertDialog.Builder(context);
    alert.setMessage(message);
    return alert;
}

From source file:Main.java

public static void displayInfoBox(Activity activity, final String title, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message).setCancelable(false).setTitle(title).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();//from   www.  j a  v a  2 s.c  om
                }
            });
    AlertDialog alert = builder.create();

    alert.show();
}

From source file:Main.java

public static void showMessageDialogWithFinish(final Activity object, Context context, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(message).setCancelable(false).setPositiveButton("Ok",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    object.finish();//from  w w w . ja v a 2s.c om

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

From source file:Main.java

public static void displayErrorAlert(String msg, Context ctxt) {
    if (ctxt != null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(ctxt);
        builder.setMessage(msg).setCancelable(false).setNeutralButton("Ok", null).show();
    }/*from   w  ww .j  a va 2s  .c om*/
}

From source file:Main.java

/**
 * Creates a confirmation dialog that show a pop-up with button labeled as parameters labels.
 *
 * @param ctx                 {@link Activity} {@link Context}
 * @param message             Message to be shown in the dialog.
 * @param dialogClickListener For e.g./*from  w  w w  .ja va  2 s  .  c o m*/
 *                            <p/>
 * @param positiveBtnLabel    For e.g. "Yes"
 * @param negativeBtnLabel    For e.g. "No"
 *
 */
public static void showDialog(Context ctx, String message, String positiveBtnLabel, String negativeBtnLabel,
        DialogInterface.OnClickListener dialogClickListener) {

    if (dialogClickListener == null) {
        throw new NullPointerException("Action listener cannot be null");
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);

    builder.setMessage(message).setPositiveButton(positiveBtnLabel, dialogClickListener)
            .setNegativeButton(negativeBtnLabel, dialogClickListener).show();
}

From source file:Main.java

public static AlertDialog createErrorDialog(final Activity activity, String title, String message,
        final boolean doFinish) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message);
    builder.setTitle(title);/*from w ww. j  a  v a  2 s  . c om*/
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (doFinish) {
                activity.finish();
            }
        }
    });
    return builder.create();
}

From source file:Main.java

public static void displayAlertDialog(String text, final Context context, final boolean closeActivity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setMessage(text);
    builder.setCancelable(false);// www  . j  a v a 2s. com
    builder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            if (closeActivity) {
                ((Activity) context).finish();
            } else {
                dialogInterface.dismiss();
            }
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:Main.java

public static void alertTurnOnGPS(final Context mContext) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage("Do you want to enable GPS?").setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    mContext.startActivity(
                            new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }//from  w  w  w.  j a v  a 2 s .co m
            }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(final DialogInterface dialog, final int id) {
                    dialog.cancel();
                }
            });
    final AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

static public void showDialogBox(String message, Context context) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setMessage(message);

    alertDialogBuilder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {

        @Override/*from  w w w .j  a  va 2s. c  o  m*/
        public void onClick(DialogInterface arg0, int arg1) {

        }
    });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}