List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:Main.java
public static void yesNoMessage(final Activity activity, final String title, final String body, final String yesButtonLabel, final String noButtonLabel, final Runnable yesRunnable, final Runnable noRunnable) { activity.runOnUiThread(new Runnable() { @Override// w ww . java 2s . c om public void run() { AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setTitle(title); dialog.setMessage(body); dialog.setPositiveButton(yesButtonLabel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (yesRunnable != null) yesRunnable.run(); } }); dialog.setNegativeButton(noButtonLabel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (noRunnable != null) noRunnable.run(); } }); dialog.create(); dialog.show(); } }); }
From source file:Main.java
public static void showGPSSettings(final Activity activity) { // check for internet connection AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity); alertDialog.setTitle("GPS adapter disabled"); alertDialog.setMessage("GPS is not enabled. Please enable GPS"); // Setting Positive "Yes" Button alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }//ww w. j a v a 2 s .com }); // Setting Negative "NO" Button alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
From source file:Main.java
/** * This method shows an alert box with specified message * @param context// w w w . j a v a 2s . c o m * @param message */ public static void displayAlert(final Context context, String message) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle("Yumm! Alert:"); alert.setMessage(message); alert.setCancelable(false); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:Main.java
public static void showConfirmDialog(Context context, String title, String message, String strPositiveButton, String strNegativeButton, DialogInterface.OnClickListener positiveOnclick, DialogInterface.OnClickListener negativeOnClick, boolean cancelAble, DialogInterface.OnCancelListener cancelListener) { if (context == null) { return;/* w w w. j a v a 2 s . c om*/ } AlertDialog.Builder builder = new AlertDialog.Builder(context); if (title != null) { builder.setTitle(title); } builder.setMessage(message); if (TextUtils.isEmpty(strPositiveButton)) { builder.setPositiveButton(strPositiveButton, positiveOnclick); } else { builder.setPositiveButton(strPositiveButton, positiveOnclick); } if (!TextUtils.isEmpty(strNegativeButton)) { builder.setNegativeButton(strNegativeButton, negativeOnClick); } builder.setCancelable(cancelAble); builder.setOnCancelListener(cancelListener); builder.create().show(); }
From source file:Main.java
public static void showWifiSettings(final Activity activity, final Runnable yes, final Runnable no) { // check for internet connection AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity); alertDialog.setTitle("No Internet Connection"); alertDialog.setMessage("Would you like to change settings ?"); // Setting Positive "Yes" Button alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { activity.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); if (yes != null) yes.run();/*from ww w . j a v a 2 s.c o m*/ } }); // Setting Negative "NO" Button alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); if (no != null) no.run(); } }); // Showing Alert Message alertDialog.show(); }
From source file:Main.java
/** * Creates a simple alert dialog with given params * * @param activity self explanatory//from ww w .jav a 2s . c o m * @param title self explanatory * @param message self explanatory */ public static void createAlertDialog(final Activity activity, String title, String message) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); // set title alertDialogBuilder.setTitle(title); // set dialog message alertDialogBuilder.setMessage(message).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity dialog.cancel(); activity.finish(); } }); }
From source file:Main.java
/** * build a alert dialog/* w w w. j a v a 2s . com*/ * * @param context * @param title * @param msg * @param ok * @param cancel * @param lOk * @param lCancel * @return */ public static AlertDialog buildAlert(Context context, Integer title, Integer msg, Integer ok, Integer cancel, DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) { AlertDialog.Builder builder = new AlertDialog.Builder(context); if (title != null) builder.setTitle(title); if (msg != null) builder.setMessage(msg); if (ok != null) builder.setPositiveButton(ok, lOk); if (cancel != null) builder.setNegativeButton(cancel, lCancel); return builder.create(); }
From source file:Main.java
/** * build a alert dialog/*ww w. ja v a 2 s. c o m*/ * * @param context * @param title * @param msg * @param ok * @param cancel * @param lOk * @param lCancel * @return */ public static AlertDialog buildAlert(Context context, CharSequence title, CharSequence msg, CharSequence ok, CharSequence cancel, DialogInterface.OnClickListener lOk, DialogInterface.OnClickListener lCancel) { AlertDialog.Builder builder = new AlertDialog.Builder(context); if (title != null) builder.setTitle(title); if (msg != null) builder.setMessage(msg); if (ok != null) builder.setPositiveButton(ok, lOk); if (cancel != null) builder.setNegativeButton(cancel, lCancel); return builder.create(); }
From source file:Main.java
public static void showServiceError(Context context, int id) { String msg = ""; if (id == -1) { msg = "could not complete query. Missing parameter"; } else if (id == 0) { msg = "no data found"; } else {/* www .j a v a2s . c o m*/ msg = "something bad happend"; } AlertDialog.Builder alert = new AlertDialog.Builder(context); // Setting Dialog Title alert.setTitle("Alarm"); // Setting Dialog Message alert.setMessage(msg); alert.setPositiveButton("Try Again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // chkVersionData(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); alert.setCancelable(false); alert.show(); }
From source file:Main.java
public static void DisplayAlertOKCancel(final Context context, final String title, final String message) { retValue = -1;//from ww w . j av a 2 s.c o m final Activity activity = (Activity) context; activity.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 1; alert = null; } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { retValue = 0; alert = null; } }); alert = builder.create(); alert.show(); } }); }