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

public static void showMessage(String message, Context context) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle("New Message");
    alertDialog.setMessage(message);/*from   w  w  w . j a v a2 s . c  o m*/
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    alertDialog.show();
}

From source file:net.vexelon.myglob.utils.Utils.java

/**
 * Display alert dialog using string message
 * @param context/* www. j  a  va  2s . c o  m*/
 * @param message
 * @param titleResId
 */
public static void showAlertDialog(Activity activity, String message, String title) {
    final Activity act = activity;
    final String s1 = message, s2 = title;
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            AlertDialog alert = createAlertDialog(act, s1, s2);
            alert.show();
        }
    });
}

From source file:Main.java

public static void displayAlert(Context context, String title, String message, String buttonText) {
    AlertDialog alertDialog = new AlertDialog.Builder(context)
            .setPositiveButton(buttonText, new DialogInterface.OnClickListener() {
                @Override/* ww w . ja  va2  s  .  c  o m*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).setTitle(title).setMessage(message).create();

    alertDialog.show();
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static void setupOnLinkClick(final Context context, final String url, final TextView textView) {
    textView.setOnClickListener(new View.OnClickListener() {
        @Override/*  ww  w .  j  a v  a  2 s  .  c  om*/
        public void onClick(View v) {
            AlertDialog.Builder imageDialog = new AlertDialog.Builder(context);
            ProgressBar progressBar = new ProgressBar(context);
            imageDialog.setView(progressBar);
            AlertDialog progressDialog = imageDialog.create();
            progressDialog.show();
            new GetImageAsyncTask(new AsyncTaskCompletionNotifierImagePopup(context, progressDialog))
                    .execute(url);
        }
    });
}

From source file:Main.java

static public void showAlert(Context ctx, final String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
    alertDialog.setTitle("Application Error");
    alertDialog.setMessage(message);//from  w ww.  j a v  a  2 s  . c o m
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Dismiss", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Do nothing
        }
    });
    alertDialog.show();
}

From source file:Main.java

public static AlertDialog showAlertMessage(String title, String message, Context context) {
    final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);//  www.  j  a  va 2s. c  om
    alertDialog.setMessage(message);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();
    return alertDialog;
}

From source file:Main.java

public static void showMsgBox(Context c, String title, String msg) {
    AlertDialog ad = new AlertDialog.Builder(c).create();
    ad.setCancelable(false); // This blocks the 'BACK' button
    ad.setMessage(msg);/*from ww w  .j  av  a 2 s . com*/
    ad.setTitle(title);
    ad.setButton(OK, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    ad.show();
}

From source file:Main.java

public static void displayInfo(Context context, String title, String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);//w  ww. j a  v a 2s .co  m
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:Main.java

public static void displayAlert(Context context, String title, String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);/* w w  w  .  j ava2 s.  c  o  m*/
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:Main.java

public static AlertDialog showYesNoAlert(Context context, boolean good, int titleId, int messageId,
        DialogInterface.OnClickListener positiveListener, DialogInterface.OnClickListener negativeListener) {
    final AlertDialog dialog = new AlertDialog.Builder(context)
            .setIcon(good ? android.R.drawable.ic_menu_info_details
                    : android.R.drawable.ic_menu_close_clear_cancel)
            .setTitle(titleId).setMessage(messageId).setPositiveButton(android.R.string.ok, positiveListener)
            .setNegativeButton(android.R.string.no, negativeListener).create();
    dialog.show();
    return dialog;
}