Example usage for android.app AlertDialog.Builder setMessage

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

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:Main.java

public static void showDialogOkWithGoBack(String title, String message, final Activity activity) {
    if (activity.getApplicationContext() != null) {
        AlertDialog.Builder adb = new AlertDialog.Builder(activity);
        adb.setTitle(title);/*from  w  ww .j av  a 2 s . c  o m*/
        adb.setMessage(message);
        adb.setCancelable(false);
        adb.setNeutralButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
                //activity.onBackPressed();
            }
        });
        AlertDialog ad = adb.create();
        ad.setVolumeControlStream(AudioManager.STREAM_MUSIC);
        ad.show();
    }
}

From source file:Main.java

public static void showMessage(Context _context, String title, String message, int icon,
        DialogInterface.OnClickListener ackHandler) {
    try {//from  w  w  w  . ja  va  2 s  .  c o  m
        AlertDialog.Builder builder = new AlertDialog.Builder(_context);
        builder.setTitle(title);
        builder.setMessage(Html.fromHtml(message));
        builder.setCancelable(false);
        builder.setPositiveButton("Acknowledged", ackHandler);
        builder.setIcon(icon);
        builder.show();
    } catch (Exception e) {
    }
}

From source file:Main.java

/**
 * Returns an Alert Dialog with one button and title.
 * @param context               -The activity which need this alert.
 * @param title                 -The alert title.
 * @param message               -The alert message.
 * @param positiveBtnLabel      -The positive button label.
 * @param positiveClickListener -The positive button listener.
 * @return - An alert dialog./*ww w .  j  a v a 2s.c  o  m*/
 */
public static AlertDialog.Builder getAlertDialogWithOneButtonAndTitle(Context context, String title,
        String message, String positiveBtnLabel, DialogInterface.OnClickListener positiveClickListener) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener);
    builder.show();
    return builder;
}

From source file:Main.java

/**
 * Returns an Alert Dialog with one button and title.
 * /* w w  w.  ja v  a2 s  .c  om*/
 * @param context the activity which need this alert.
 * @param title the alert title
 * @param message the alert message
 * @param positiveBtnLabel the positive button label
 * @param positiveClickListener the positive button listener
 * 
 * @return an alert dialog
 */
public static AlertDialog.Builder getAlertDialogWithOneButtonAndTitle(Context context, String title,
        String message, String positiveBtnLabel, DialogInterface.OnClickListener positiveClickListener) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener);

    return builder;
}

From source file:Main.java

public static AlertDialog.Builder dialogBuilder(Context context, String title, String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (msg != null) {
        builder.setMessage(msg);
    }/*www.j  a v a 2s.com*/
    if (title != null) {
        builder.setTitle(title);
    }
    return builder;
}

From source file:Main.java

public static AlertDialog.Builder dialogBuilder(Context context, String title, String msg, int i) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (msg != null) {
        builder.setMessage(Html.fromHtml(msg));
    }/* w  ww .  j a  va2  s .  c  o m*/
    if (title != null) {
        builder.setTitle(title);
    }
    return builder;
}

From source file:Main.java

public static void showDialog(Activity context, String strTitle, String strText, int icon) {
    AlertDialog.Builder tDialog = new AlertDialog.Builder(context);
    tDialog.setIcon(icon);/*w  ww  . j  a  v  a2  s  .  c o  m*/
    tDialog.setTitle(strTitle);
    tDialog.setMessage(strText);
    tDialog.setPositiveButton("Sure", null);
    tDialog.show();
}

From source file:Main.java

public static AlertDialog genericOneButtonAlertWithListener(Context mContext, String title, String msg,
        String button, DialogInterface.OnClickListener listener) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext);
    alertDialogBuilder.setTitle(title);// ww  w .  ja  va 2  s.  com

    alertDialogBuilder.setMessage(msg).setCancelable(true).setPositiveButton(button, listener);

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

    // show it
    return alertDialog;
}

From source file:Main.java

/**
 * Return an Alert Dialog with two buttons and a title.
 * @param context              - The Activity which needs this alert dialog.
 * @param title                - The title of the message.
 * @param message              - The message in the alert.
 * @param positiveBtnLabel     - The label of the positive button.
 * @param negetiveBtnLabel     - The label of the negative button.
 * @param positiveClickListener- The onClickListener of the positive button.
 * @param negativeClickListener- The onClickListener of the negative button.
 * @return - The generated Alert Dialog.
 *///ww  w  .j  a v a2  s.c  o  m
public static AlertDialog.Builder getAlertDialogWithTwoButtonAndTitle(Context context, String title,
        String message, String positiveBtnLabel, String negetiveBtnLabel,
        DialogInterface.OnClickListener positiveClickListener,
        DialogInterface.OnClickListener negativeClickListener) {

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage(message).setPositiveButton(positiveBtnLabel, positiveClickListener)
            .setNegativeButton(negetiveBtnLabel, negativeClickListener);

    return builder;
}

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);/*from   w w w  . j a v a2s  .  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;
}