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:org.gplvote.signdoc.MainActivity.java

public static void alert(String text, final Activity activity, final boolean parent_exit) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.title_warning).setIcon(R.drawable.notification_icon).setMessage(text)
            .setCancelable(false).setNegativeButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();//from w  w w.  j a  va  2  s .  com
                    if (parent_exit) {
                        activity.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.gplvote.signdoc.MainActivity.java

public static void error(String text, final Activity activity, final boolean parent_exit) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.title_error).setIcon(R.drawable.cancel_icon).setMessage(text).setCancelable(false)
            .setNegativeButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();//from   ww  w.  j ava2 s . com
                    if (parent_exit) {
                        activity.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:net.naonedbus.utils.InfoDialogUtils.java

/**
 * Afficher une dialog avec titre et message personnaliss
 * // ww  w  .j a  v  a  2s . c  o  m
 * @param context
 * @param titleId
 * @param messageId
 */
public static void show(final Context context, final int titleId, final int messageId) {
    final AlertDialog moreDetailsDialog = getDialog(context, titleId, messageId);
    moreDetailsDialog.show();
}

From source file:com.nadmm.airports.utils.NetworkUtils.java

public static void checkNetworkAndDownload(Context context, final Runnable runnable) {
    if (!NetworkUtils.isNetworkAvailable(context)) {
        UiUtils.showToast(context, "Please check your internet connection");
    }//w w  w.  j a v a  2  s. co  m

    if (NetworkUtils.isConnectedToMeteredNetwork(context)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage("You are conneteced to a metered network such as mobile data"
                + " or tethered to mobile data.\nContinue download?")
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        runnable.run();
                    }
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    } else {
        runnable.run();
    }
}

From source file:Main.java

public static Dialog confirm(String title, View view, Context context,
        DialogInterface.OnClickListener onConfirmListener) {
    Builder dialogBuilder = confirmBuilder(title, context, onConfirmListener).setView(view);

    if (view instanceof TextView) {
        ScrollView scrollView = new ScrollView(context);
        scrollView.addView(view);/*from  ww  w  .j ava 2  s. c o  m*/
        dialogBuilder.setView(scrollView);
    }

    AlertDialog dialog = dialogBuilder.create();

    if (view instanceof EditText) {
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
                | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    dialog.show();
    return dialog;
}

From source file:Main.java

public static void showAlert(String msg, Context context) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle("Alert");
    alertDialog.setMessage(msg);//from   w w w. j  a  v  a 2  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:Main.java

public static void showAlertDialog(Context ctx, String title, String message) {

    AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
    alertDialog.setTitle(title);/*from  www  . ja  v a  2  s.  c o m*/
    alertDialog.setMessage(message);

    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

        }
    });
    alertDialog.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 OnClickListener() {

                @Override/*  w w w  .ja  v  a2 s .  c o  m*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).setTitle(title).setMessage(message).create();

    alertDialog.show();
}

From source file:Main.java

public static void showWarningDialogStatic(String title, String message, Context ctx) {
    AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
    alertDialog.setTitle(title);/*from  w ww.j a v  a 2  s .  c  o  m*/
    alertDialog.setMessage(message);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // here you can add functions
        }
    });
    alertDialog.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  . jav a 2 s  .  co m*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).setTitle(title).setMessage(message).create();

    alertDialog.show();
}