Example usage for android.app AlertDialog.Builder setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

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);
        adb.setMessage(message);//  w w  w .  jav a  2 s. co  m
        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 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);

    alertDialogBuilder.setMessage(msg).setCancelable(true).setNegativeButton(noButton, noListener)
            .setPositiveButton(yesButton, yesListener);

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

    // show it//from  w  w  w.  ja va 2 s.co  m
    return alertDialog;
}

From source file:Main.java

public static void openAbout(Activity a) {
    Log.d("about", "openAbout has been called");
    //Log.d("context", "context = "+ c.toString());
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(a);

    alertDialogBuilder.setTitle("About");

    alertDialogBuilder.setMessage(//from  w w w .  j  a  va2 s. c  om
            "This app was developed for CS160 at UC Berkeley by:\n\nDominic Kong \nPatrick Lin \nMeghana Seshadri \nJane Sima")
            .setCancelable(true).setNeutralButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

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./*from   w  w  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

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

From source file:Main.java

public static final Dialog createErrorAlert(final Context context, final String title, final String message) {

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);

    final Dialog dialog = builder.setTitle(title).setMessage(message)
            .setIcon(android.R.drawable.ic_dialog_alert).setNeutralButton("OK", null).create();

    return dialog;
}

From source file:Main.java

/**
 * Returns an Alert Dialog with one button and title.
 * /*from ww  w . j  a v  a2 s.c  o m*/
 * @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

/**
 * //  w w  w  . j a  va  2s. co m
 * @param context
 * @param title
 * @param message
 */
public static void showAlert(Context context, String title, String message) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    alertDialogBuilder.setTitle(title).setMessage(message).setCancelable(false).setNeutralButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, close
                    // current activity
                    dialog.dismiss();
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();
}

From source file:Main.java

private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle,
        CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo) {
    AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
    downloadDialog.setTitle(stringTitle);
    downloadDialog.setMessage(stringMessage);
    downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
            Uri uri = Uri.parse("market://search?q=pname:org.torproject.android");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            activity.startActivity(intent);
        }//www .  j  a  v  a2s  .c  o m
    });
    downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    });
    return downloadDialog.show();
}

From source file:Main.java

public static void getRingtonesDialog(Activity activity, Collection<String> items, int selected,
        DialogInterface.OnClickListener itemClickListener, DialogInterface.OnClickListener okClickListener,
        final DialogInterface.OnClickListener cancelClickListener) {
    AlertDialog.Builder builderSingle = new AlertDialog.Builder(activity);
    builderSingle.setTitle("Select Ringtone");
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity,
            android.R.layout.select_dialog_singlechoice);
    arrayAdapter.addAll(items);/*from w  w  w .j  a v a  2  s . c  o m*/

    builderSingle.setNegativeButton(android.R.string.cancel, cancelClickListener);

    builderSingle.setPositiveButton(android.R.string.ok, okClickListener);

    builderSingle.setSingleChoiceItems(arrayAdapter, selected, itemClickListener);

    builderSingle.setCancelable(false);

    builderSingle.show();
}