List of usage examples for android.app AlertDialog setButton
@Deprecated public void setButton(CharSequence text, final OnClickListener listener)
From source file:com.max2idea.android.fwknop.Fwknop.java
public static void UIAlert(String title, String body, Activity activity) { AlertDialog ad; ad = new AlertDialog.Builder(activity).create(); ad.setTitle(title);//from w w w.j a v a 2 s . co m ad.setMessage(body); ad.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); ad.show(); }
From source file:com.jonathongrigg.apps.spark.MainActivity.java
public void showAboutDialog() { final AlertDialog aboutDialog = new AlertDialog.Builder(this).create(); aboutDialog.setTitle(this.getText(R.string.dialog_title)); aboutDialog.setMessage(this.getText(R.string.dialog_text)); aboutDialog.setIcon(R.drawable.ic_menu_info_details); aboutDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { aboutDialog.dismiss();/* w w w.j a v a 2 s . c o m*/ } }); aboutDialog.show(); }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
public static void deleteSeriesAlert(Context context, final CatalogueDBAdapter dbHelper, final Series series, final Runnable onDeleted) { // When we get here, we know the names are genuinely different and the old series is used in more than one place. String message = "Delete series"; try {/*from ww w. j av a2s. c om*/ message = String.format(context.getResources().getString(R.string.really_delete_series), series.name); } catch (NullPointerException e) { Logger.logError(e); } final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create(); alertDialog.setTitle(R.string.delete_series); alertDialog.setIcon(android.R.drawable.ic_menu_info_details); //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { alertDialog.setButton2(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dbHelper.deleteSeries(series); alertDialog.dismiss(); onDeleted.run(); } }); //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { alertDialog.setButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); }
From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java
public static int deleteBookAlert(Context context, final CatalogueDBAdapter dbHelper, final long id, final Runnable onDeleted) { ArrayList<Author> authorList = dbHelper.getBookAuthorList(id); String title;// w ww . j a v a 2 s.c o m Cursor cur = dbHelper.fetchBookById(id); try { if (cur == null || !cur.moveToFirst()) return R.string.unable_to_find_book; title = cur.getString(cur.getColumnIndex(CatalogueDBAdapter.KEY_TITLE)); if (title == null || title.length() == 0) title = "<Unknown>"; } finally { if (cur != null) cur.close(); } // Format the list of authors nicely String authors; if (authorList.size() == 0) authors = "<Unknown>"; else { authors = authorList.get(0).getDisplayName(); for (int i = 1; i < authorList.size() - 1; i++) { authors += ", " + authorList.get(i).getDisplayName(); } if (authorList.size() > 1) authors += " " + context.getResources().getString(R.string.list_and) + " " + authorList.get(authorList.size() - 1).getDisplayName(); } // Get the title String format = context.getResources().getString(R.string.really_delete_book); String message = String.format(format, title, authors); final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create(); alertDialog.setTitle(R.string.menu_delete); alertDialog.setIcon(android.R.drawable.ic_menu_info_details); //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { alertDialog.setButton2(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dbHelper.deleteBook(id); alertDialog.dismiss(); onDeleted.run(); } }); //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { alertDialog.setButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); return 0; }
From source file:org.openremote.android.console.view.PanelSelectSpinnerView.java
@Override public void urlConnectionDidReceiveResponse(HttpResponse httpResponse) { int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != Constants.HTTP_SUCCESS) { if (statusCode == ControllerException.UNAUTHORIZED) { LoginDialog loginDialog = new LoginDialog(getContext()); loginDialog.setOnClickListener(loginDialog.new OnloginClickListener() { @Override//from w ww. j av a 2s . com public void onClick(View v) { super.onClick(v); requestPanelList(getContext(), PanelSelectSpinnerView.this); } }); } else { // The following code customizes the dialog, because the finish method should do after dialog show and click ok. AlertDialog alertDialog = new AlertDialog.Builder(getContext()).create(); alertDialog.setTitle("Panel List Not Found"); alertDialog.setMessage(ControllerException.exceptionMessageOfCode(statusCode)); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); setDefaultAdapterContent(); } } }
From source file:com.abcvoipsip.ui.calllog.CallLogListFragment.java
private void deleteAllCalls() { AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle(R.string.callLog_delDialog_title); alertDialog.setMessage(getString(R.string.callLog_delDialog_message)); alertDialog.setButton(getString(R.string.callLog_delDialog_yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null, null); }//from w ww .j a va 2s. co m }); alertDialog.setButton2(getString(R.string.callLog_delDialog_no), (DialogInterface.OnClickListener) null); try { alertDialog.show(); } catch (Exception e) { Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog"); } }
From source file:dk.kasperbaago.JSONHandler.JSONHandler.java
/** * Shows an error to the user, if the request fails. * Callback is NOT called if this is shown. To still run callback and use your own error handler, use showErrMsg(false); */// w w w .j a v a 2 s .c o m private void showErrorMsg() { AlertDialog alert = new AlertDialog.Builder(this.context).create(); alert.setTitle(this.errorMsgTitle); alert.setMessage(this.errorMsgTxt); alert.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); }
From source file:com.example.yudiandrean.socioblood.ChangePassword.java
/** * Called when the activity is first created. */// w ww.j a v a2 s.c o m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.changepassword); cancel = (Button) findViewById(R.id.btcancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { Intent login = new Intent(getApplicationContext(), LoginActivity.class); startActivity(login); finish(); } }); newpass = (EditText) findViewById(R.id.newpass); verifynewpass = (EditText) findViewById(R.id.verifynewpass); alert = (TextView) findViewById(R.id.alertpass); changepass = (Button) findViewById(R.id.btchangepass); changepass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (newpass.getText().toString().equals("")) { AlertDialog alertDialog = new AlertDialog.Builder(ChangePassword.this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Password field is empty"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //dismiss the dialog } }); alertDialog.show(); } else if (!verifynewpass.getText().toString().equals(newpass.getText().toString())) { AlertDialog alertDialog = new AlertDialog.Builder(ChangePassword.this).create(); alertDialog.setTitle("Error"); alertDialog.setMessage("Passwords do not match, try again!"); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //dismiss the dialog } }); alertDialog.show(); } else { NetAsync(view); } } }); }
From source file:bikebadger.RideActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.d("Bike Badger", "RideActivity::onCreate"); super.onCreate(savedInstanceState); Context context = getApplicationContext(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); AppManager.AppStartEnum startMode = AppManager.CheckAppStart(getApplicationContext(), preferences); //startMode = AppManager.AppStartEnum.EXPIRED_FREE; //startMode = AppManager.AppStartEnum.DISABLED; switch (startMode) { case DISABLED: AlertDialog finishAlert = new AlertDialog.Builder(this).create(); finishAlert.setCancelable(false); finishAlert.setTitle("Trial Expired"); finishAlert.setMessage("Your trial has expired. Please consider purchasing the full version."); finishAlert.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //RideManager rm = RideManager.get(RideActivity.this); //if(rm != null) // rm.Shutdown(); RideActivity.this.finish(); //dialog.dismiss(); }/* w ww .j a va2 s. co m*/ }); finishAlert.show(); break; case EXPIRED_FREE: // expired trail. Let them purchase or do nothing. AppManager.PurchaseDialog(this); break; case NORMAL_FREE: // Still counting down the expiry. Do nothing break; case NORMAL_PAID: // TODO Until I figure out what this overly complicated thing does, don't use it // If it is merely to prevent folks from side-loading a copy they somehow get a hold of, they // deserve a free version // checkLicense(); // all is well. Do nothing break; case FIRST_TIME_FREE: // the version number ends in .free AppManager.CopyAssetFileOrDir("empty.gpx", context); AppManager.CopyAssetFileOrDir("EnchiladaBuffet_Austin.gpx", context); AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context); // conditional shows the version notes (only if the version has changed) VersionNotes myNotes = new VersionNotes(this); myNotes.showVersionNotes(); break; case FIRST_TIME_PAID: AppManager.CopyAssetFileOrDir("empty.gpx", context); AppManager.CopyAssetFileOrDir("EnchiladaBuffet_Austin.gpx", context); AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context); // TODO Until I figure out what this overly complicated thing does, don't use it // If it is merely to prevent folks from side-loading a copy they somehow get a hold of, they // deserve a free version // checkLicense(); // conditional shows the version notes (only if the version has changed) VersionNotes myNotes2 = new VersionNotes(this); myNotes2.showVersionNotes(); break; case FIRST_TIME_VERSION: AppManager.CopyAssetFileOrDir("BikeBadger.pdf", context); // conditional shows the version notes (only if the version has changed) VersionNotes myNotes1 = new VersionNotes(this); myNotes1.showVersionNotes(); break; } if (AppManager.IsPackageInstalled("net.dinglisch.android.taskerm", context)) { Log.d(Constants.APP.TAG, "Tasker Installed"); } if (AppManager.IsPackageInstalled("com.strava", context)) { Log.d(Constants.APP.TAG, "Strava Installed"); } else { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.apps.maps")); startActivity(intent); } if (AppManager.IsPackageInstalled("com.maxmpz.audioplayer", context)) { Log.d(Constants.APP.TAG, "PowerAMP Installed"); } }
From source file:devza.app.android.droidnetkey.FirewallAction.java
@Override protected void onPostExecute(Integer result) { /*INVALID_CREDENTIALS = -1; TIMED_OUT = -2;// ww w .j a va 2 s. c o m GENERAL_ERROR = -3;*/ if (!refresh) { d.dismiss(); if (result < 0) { AlertDialog error = new AlertDialog.Builder(this.context).create(); error.setTitle("Error"); error.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int id) { d.cancel(); } }); String msg; switch (result) { case INVALID_CREDENTIALS: msg = "Invalid Username or Password"; break; case TIMED_OUT: msg = "Connection Timed Out. Is your device connected to the internet?"; break; case UNKNOWN_HOST: msg = "Could not connect. Is your device connected to the internet?"; break; case GENERAL_ERROR: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; default: msg = "General Error.\n Please send some more information about this error to 15629368@sun.ac.za"; break; } error.setMessage(msg); error.show(); } else { if (result == CONNECTED) { Intent usage = new Intent(this.context, UsageActivity.class); this.context.startActivity(usage); this.s.showNotification(true); this.s.startTimer(); } else { Intent main = new Intent(this.context, MainActivity.class); this.context.startActivity(main); this.s.showNotification(false); } } } }