Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:Main.java

/**
 * @param s//from  www . jav  a2 s. c  om
 *            The alert message Displays an alert dialog with the messaged
 *            provided
 */
public static void showAlert(Context context, String mesg) {
    AlertDialog.Builder alt_bld = new AlertDialog.Builder(context);
    alt_bld.setMessage(mesg).setPositiveButton(android.R.string.ok, null);
    AlertDialog alert = alt_bld.create();
    alert.show();
}

From source file:Main.java

public static final void showAlertDialog(Activity ctx, String title, String text) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(ctx);
    alertBuilder.setTitle(title);/*from ww  w  . j av a2  s . c o m*/
    alertBuilder.setMessage(text);
    AlertDialog alert = alertBuilder.create();
    alert.show();
}

From source file:Main.java

public static void showDialog(AlertDialog alertdialog) {
    try {/*from  w ww .  j  ava2  s.  c o m*/
        alertdialog.show();
        return;
    } catch (Exception exception) {
        return;
    }
}

From source file:Main.java

public static void showProgressDialog(Context mCtx, String msg) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mCtx);
    builder.setMessage(msg);//from w w  w  .j a v  a2  s  .c  om
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:Main.java

public static void showInfoDialog(Context ctx, String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    builder.setMessage(msg);//from w  w w  .  ja  va2s  .  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:Main.java

public static void alert(String title, String message, Activity activity,
        DialogInterface.OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);/*from  ww  w . j  ava 2 s  .co  m*/
    builder.setMessage(message);
    builder.setPositiveButton("OK", listener);
    AlertDialog alert = builder.create();
    alert.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();/*from  ww  w . j a  va  2s . co m*/
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

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();/*  www.  j  a  va 2s. co m*/
                }
            });
    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 .  j ava  2s .  co m*/

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

From source file:Main.java

public static void createCancellableAcceptDialog(Context context, String title, String message,
        String acceptButtonText, final Runnable onAccept) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);/*from   w  w w  . ja  v  a 2s  .  co m*/
    builder.setMessage(message);
    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onAccept != null)
                onAccept.run();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}