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

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/*w w w. ja  va  2 s.c om*/
        public void onClick(DialogInterface arg0, int arg1) {

        }
    });

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

From source file:Main.java

public static void DialogOK(Context ctx, String text) {
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setMessage(text).setCancelable(false).setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();/*  ww  w  .  j  a  va 2s.  c om*/
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void showAlertWithImage(String title, String msg, Context context, ImageView image) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(title).setMessage(msg)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override/*from w  ww  . j  a v a 2s  .c  om*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).setView(image);
    builder.create().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();/*ww w .  ja  v a 2  s  .c  o  m*/

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

From source file:Main.java

public static AlertDialog newYesNoDialog(final Activity activity, String dialogTitle, String screenMessage,
        int iconResourceId, OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setCancelable(false);/*from   w ww.  j av a  2s.c om*/
    builder.setPositiveButton(android.R.string.yes, listener);
    builder.setNegativeButton(android.R.string.no, listener);

    builder.setTitle(dialogTitle);
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}

From source file:Main.java

/**
 * build a alert dialog//from w  ww  . j a v  a 2s .c o  m
 *
 * @param context
 * @param title
 * @param msg
 * @param ok
 * @param cancel
 * @param lOk
 * @param lCancel
 * @return
 */
public static AlertDialog buildAlert(Context context, Integer title, Integer msg, Integer ok, Integer cancel,
        DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (title != null)
        builder.setTitle(title);
    if (msg != null)
        builder.setMessage(msg);
    if (ok != null)
        builder.setPositiveButton(ok, lOk);
    if (cancel != null)
        builder.setNegativeButton(cancel, lCancel);
    return builder.create();
}

From source file:Main.java

/**
 * build a alert dialog/*from   ww w  . j  av  a  2s.c om*/
 *
 * @param context
 * @param title
 * @param msg
 * @param ok
 * @param cancel
 * @param lOk
 * @param lCancel
 * @return
 */
public static AlertDialog buildAlert(Context context, CharSequence title, CharSequence msg, CharSequence ok,
        CharSequence cancel, DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (title != null)
        builder.setTitle(title);
    if (msg != null)
        builder.setMessage(msg);
    if (ok != null)
        builder.setPositiveButton(ok, lOk);
    if (cancel != null)
        builder.setNegativeButton(cancel, lCancel);
    return builder.create();
}

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   w w  w  .  ja va 2 s. c o  m
                }
            });
    AlertDialog alert = builder.create();

    alert.show();
}

From source file:Main.java

/**
 * Creates a new Yes/No AlertDialog//from   w  w  w  .ja v a  2s. co m
 * 
 * @param context
 * @param dialogTitle
 * @param screenMessage
 * @param iconResourceId
 * @param listener
 * @return
 */
public static AlertDialog newYesNoDialog(final Context context, String dialogTitle, String screenMessage,
        int iconResourceId, OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setPositiveButton(android.R.string.yes, listener);
    builder.setNegativeButton(android.R.string.no, listener);

    builder.setTitle(dialogTitle);
    builder.setMessage(screenMessage);
    builder.setIcon(iconResourceId);

    return builder.create();
}

From source file:Main.java

public static void mostrarCaixaDialogoSimples(Context context, String titulo, String mensagem) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(titulo);/*from www  .  j a  v  a2 s . c  o  m*/
    builder.setMessage(mensagem);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

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