List of usage examples for android.app AlertDialog.Builder setMessage
public void setMessage(CharSequence message)
From source file:Main.java
/** * @param context : the context that the dialog interface will be binded to * @param title : dialog title// www. j a va 2 s . c om * @param positiveButtonText * @param positiveListener * @param negativeButtonText * @param negativeListener * @param neutralButtonText * @param neutralListener * @param content : Custom View for the dialog */ public static void showDialog(Context context, String title, String positiveButtonText, OnClickListener positiveListener, String negativeButtonText, OnClickListener negativeListener, String neutralButtonText, OnClickListener neutralListener, View content) { if (alert != null) hideDialog(); AlertDialog.Builder builder = new AlertDialog.Builder(context); if (content != null) builder.setView(content); builder.setMessage(title).setCancelable(false); if (negativeButtonText != null && negativeListener != null) builder.setNegativeButton(negativeButtonText, negativeListener); else builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); if (positiveButtonText != null && positiveListener != null) { builder.setPositiveButton(positiveButtonText, positiveListener); } if (neutralButtonText != null && neutralListener != null) builder.setNeutralButton(neutralButtonText, neutralListener); alert = builder.create(); alert.show(); }
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 {// w w w . j a v a 2 s . 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:org.gc.networktester.util.Util.java
public static AlertDialog createDialog(final Activity activity, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(message).setPositiveButton(activity.getString(R.string.dialog_ok), null); AlertDialog ad = builder.create();//from w w w. jav a 2 s .c o m ad.show(); return ad; }
From source file:Main.java
/** * Shows a Dialog with a title, a message, a EditText and two Buttons for OK * and Cancel. The user can't click OK when the EditText is empty. * * @param context/* w w w.j av a 2 s .c o m*/ * The Context of the calling Activity * @param title * Title of the Dialog * @param message * Message of the Dialog * @param inputEditText * The EditText used for this Dialog. You can modify it for * example by setting the input type before passing it to this * method. You can also read the text from the calling method. * @param onOkClickListener * The Listener for clicking on the OK button. */ public static void showDialog(Context context, String title, String message, EditText inputEditText, DialogInterface.OnClickListener onOkClickListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title); alert.setMessage(message); alert.setView(inputEditText); /* * OK button */ alert.setPositiveButton(context.getString(android.R.string.ok), onOkClickListener); /* * Cancel button */ alert.setNegativeButton(context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* * Canceled. */ } }); final AlertDialog dialog = alert.show(); if (dialog != null) { /* * Disable ok button. */ dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false); /* * Dis- and enable , dependent on the text entered */ inputEditText.addTextChangedListener(new TextWatcher() { /** * Enable OK button if text entered, disable otherwise. */ public void onTextChanged(CharSequence s, int start, int before, int count) { dialog.getButton(DialogInterface.BUTTON_POSITIVE) .setEnabled(!s.toString().equals("") && isValideUrl(s.toString())); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); } }
From source file:com.lge.friendsCamera.Utils.java
public static void showAlertDialog(Context context, String title, String message, DialogInterface.OnClickListener posListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title);/* ww w .ja v a 2s. c om*/ alert.setMessage(message); alert.setPositiveButton("Ok", posListener); alert.setCancelable(false); alert.show(); }
From source file:com.lge.friendsCamera.Utils.java
public static void showSelectDialog(Context context, String title, String message, DialogInterface.OnClickListener positiveListener, DialogInterface.OnClickListener cancelListener) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title);// w w w . ja va 2 s . c o m alert.setMessage(message); alert.setPositiveButton("Ok", positiveListener); alert.setNegativeButton("Cancel", cancelListener); alert.setCancelable(false); alert.show(); }
From source file:com.lge.friendsCamera.Utils.java
public static void showTextDialog(Context context, String title, String body) { AlertDialog.Builder alert = new AlertDialog.Builder(context); alert.setTitle(title);/*from w w w. ja va2 s.c om*/ alert.setMessage(body); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.show(); }
From source file:com.ecml.ChooseSongActivity.java
/** Show an error dialog with the given message */ public static void showErrorDialog(String message, Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(message); builder.setCancelable(false);/*from ww w .ja v a2s . co m*/ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:it.uniroma2.foundme.studente.UnFollowCourseActivity.java
public static void alertMessage(final String info) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: extractData(info);//from w ww .j a v a 2 s . co m //new deleteCourse().execute(title, prof, Sid) try { managefollowing(title, prof, Sid); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } break; case DialogInterface.BUTTON_NEGATIVE: break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(Variables_it.UNFOLLOW_REQUEST).setNegativeButton(Variables_it.NO, dialogClickListener) .setPositiveButton(Variables_it.YES, dialogClickListener).show(); }
From source file:Main.java
public static AlertDialog newYesNoDialog(Context context, String s, String s1, int i, android.content.DialogInterface.OnClickListener onclicklistener) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context); builder.setCancelable(false);/* w w w . ja va 2s . c o m*/ builder.setPositiveButton(0x1040013, onclicklistener); builder.setNegativeButton(0x1040009, onclicklistener); builder.setTitle(s); builder.setMessage(s1); builder.setIcon(i); return builder.create(); }