Example usage for android.app AlertDialog.Builder create

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

Introduction

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

Prototype

public void create() 

Source Link

Document

Forces immediate creation of the dialog.

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);//  w ww  .j a  v a 2 s  .  c  om
    alertbox.setNegativeButton(btn, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

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

From source file:Main.java

public static void showMessage(Context context, String title, String message, OnDismissListener listener) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set title/*from  w w w  .j  a va  2 s. c  o  m*/
    alertDialogBuilder.setTitle(title);

    // set dialog message
    alertDialogBuilder.setMessage(message).setCancelable(true);

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.setCanceledOnTouchOutside(true);
    if (listener != null)
        alertDialog.setOnDismissListener(listener);
    // show it
    alertDialog.show();
}

From source file:Main.java

public static void showOKAlert(Context context, String message) {

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

    builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();//ww w .j av  a2  s . c o m
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void showInfoDialog(Context ctx, String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setMessage(msg);/*  w ww.  ja  v  a  2  s  . com*/
    builder.setPositiveButton(ctx.getString(android.R.string.ok), new OnClickListener() {
        public void onClick(DialogInterface dialog, int arg1) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.gc.networktester.util.Util.java

public static AlertDialog createDialog(final Activity activity, String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message).setPositiveButton(activity.getString(R.string.dialog_ok), null);
    AlertDialog ad = builder.create();
    ad.show();//from  www  . j a va 2 s. c o m
    return ad;
}

From source file:Main.java

/**
 * Dialog// w  w  w.  j av  a 2 s.  c  o  m
 * @param context
 * @param iconId
 * @param title
 * @param message
 * @param positiveBtnName
 * @param negativeBtnName
 * @param positiveBtnListener
 * @param negativeBtnListener
 * @return
 */
public static Dialog createConfirmDialog(Context context, int iconId, String title, String message,
        String positiveBtnName, String negativeBtnName,
        android.content.DialogInterface.OnClickListener positiveBtnListener,
        android.content.DialogInterface.OnClickListener negativeBtnListener) {
    Dialog dialog = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setIcon(iconId);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(positiveBtnName, positiveBtnListener);
    builder.setNegativeButton(negativeBtnName, negativeBtnListener);
    dialog = builder.create();
    return dialog;
}

From source file:Main.java

public static void showOKAlert(Context context, int messageResourceID) {

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

    builder.setMessage(messageResourceID).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();/*  www. ja va2s  . c om*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void showTipDialog(Activity activity, String title, String dismiss) {

    AlertDialog.Builder builder = new AlertDialog.Builder(activity).setTitle(title).setNegativeButton(dismiss,
            new DialogInterface.OnClickListener() {
                @Override/* w w w.jav a 2 s  .c o  m*/
                public void onClick(DialogInterface dialogInterface, int i) {
                }
            });
    AlertDialog alertDialog = builder.create();
    builder.show();
}

From source file:Main.java

public static AlertDialog newYesNoDialog(Context context, String s, String s1, int i,
        android.content.DialogInterface.OnClickListener onclicklistener) {
    android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context);
    builder.setCancelable(false);// w w w. j a  v  a  2s  .c o  m
    builder.setPositiveButton(0x1040013, onclicklistener);
    builder.setNegativeButton(0x1040009, onclicklistener);
    builder.setTitle(s);
    builder.setMessage(s1);
    builder.setIcon(i);
    return builder.create();
}

From source file:Main.java

public static AlertDialog genericTwoButtonAlertWithListener(Context mContext, String title, String msg,
        String yesButton, String noButton, DialogInterface.OnClickListener yesListener,
        DialogInterface.OnClickListener noListener) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
    alertDialogBuilder.setTitle(title);//  w  w  w  .ja va  2 s.c  o m

    alertDialogBuilder.setMessage(msg).setCancelable(true).setNegativeButton(noButton, noListener)
            .setPositiveButton(yesButton, yesListener);

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    return alertDialog;
}