List of usage examples for android.app AlertDialog.Builder show
public void 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 {//from w w w . j a v a 2s . 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:com.todotxt.todotxttouch.util.Util.java
public static void showConfirmationDialog(Context cxt, int msgid, OnClickListener oklistener) { AlertDialog.Builder builder = new AlertDialog.Builder(cxt); // builder.setTitle(cxt.getPackageName()); builder.setMessage(msgid);//from w w w .j a va2s .c o m builder.setPositiveButton(android.R.string.ok, oklistener); builder.setNegativeButton(android.R.string.cancel, null); builder.setCancelable(true); builder.show(); }
From source file:Main.java
private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, final String uriString) { 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(uriString); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity.startActivity(intent); }/*ww w . j av a 2 s . c o m*/ }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:com.todotxt.todotxttouch.util.Util.java
public static void showConfirmationDialog(Context cxt, int msgid, OnClickListener oklistener, int titleid) { AlertDialog.Builder builder = new AlertDialog.Builder(cxt); // builder.setTitle(cxt.getPackageName()); builder.setTitle(titleid);/*from ww w. ja v a 2 s . c o m*/ builder.setMessage(msgid); builder.setPositiveButton(android.R.string.ok, oklistener); builder.setNegativeButton(android.R.string.cancel, null); builder.setCancelable(true); builder.show(); }
From source file:com.jamesgiang.aussnowcam.Utils.java
public static void About(Context c) { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c); dialogBuilder.setTitle(R.string.app_name); dialogBuilder.setIcon(R.drawable.icon); TextView textView = new TextView(c); SpannableString s = new SpannableString(c.getString(R.string.about_info)); Linkify.addLinks(s, Linkify.WEB_URLS); textView.setText(s);/*ww w. j ava 2 s . c o m*/ textView.setGravity(Gravity.CENTER); textView.setMovementMethod(LinkMovementMethod.getInstance()); dialogBuilder.setView(textView); dialogBuilder.show(); }
From source file:org.ubicompforall.cityexplorer.gui.ImportWebTab.java
/** * Display a dialog for explaining the user the process of downloading a database. *///w ww . j av a 2 s .co m private static void showDownloadDialog(Activity context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setMessage(R.string.download_dialog); builder.setTitle(R.string.download_dialog_title); builder.setPositiveButton(R.string.download_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); builder.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); }//from w w w. j av a 2s. com }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
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/*from ww w .ja va 2 s. c om*/ * 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.escabe.TraktApi.java
public static boolean Login(String u, String p) { username = u;//w w w.java 2s .c o m password = p; JSONObject data = getDataObjectFromJSON("", true); if (data == null) { AlertDialog.Builder alert = new AlertDialog.Builder(trakt.instance); alert.setTitle("Trakt.tv"); alert.setMessage("Login Failed!\nPlease check login details."); alert.setIcon(android.R.drawable.ic_dialog_alert); alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { trakt.instance.myflipper.FlipTo(MyView.SETTINGS); } }); alert.show(); return false; } else { return true; } }
From source file:Main.java
/** * Show dialog and give 2 options: go to settings or leave the app * * @param activity the activity// w w w. ja v a 2 s. c o m */ private static void showDialog(final Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle("Bluetooth is turned off"); builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON"); builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); activity.startActivity(setnfc); } }); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); activity.finish(); } }); builder.show(); }