I hate the OK/Cancel dialogs, because if my application ask somebody if (s)he really want to do something you should never answer with "Cancel".
A little example:
final AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setIcon(android.R.drawable.ic_dialog_alert);
b.setTitle("Hello World");
b.setMessage("Did you do your homework?");
b.setPositiveButton(android.R.string.yes, null);
b.setNegativeButton(android.R.string.no, null);
b.show();
Is it possible that the constants "yes" and "no" really means "yes" and "no" with localization? Or have I do this explicit in my string resource and can't use global constants. So I replace the two lines with:
b.setPositiveButton("Yes", null);
b.setNegativeButton("No", null);
(or the resources instead of constants here)
Sincerely xZise
confirm() method, which contains the confirmation message string, ok, and cancel button. The programmer can't change the confirm box style and button label if they use the default confirm box.
You can create a JavaScript confirmation box that offers yes and no options by using the confirm() method. The confirm() method will display a dialog box with a custom message that you can specify as its argument.
Be aware that the contents of these text resources in English are actually "OK" and "Cancel", not Yes and No. So if you need Yes and No, you must use your own string resources. See for example http://code.google.com/p/android/issues/detail?id=3713 and http://groups.google.com/group/android-developers/browse_thread/thread/30b589fa9aca185a
A quick google search reveals that there are several apps that do exactly that, including Google's own My Tracks app, so I'd say it's safe to use android.R.string.yes.
Example: http://mytracks.googlecode.com/hg/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java?r=5ebff81c1c25d9600efb5d88eecc3e068ec22ae9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With