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 instea开发者_开发技巧d of constants here)
Sincerely xZise
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
What you have provided should work. (An aside, in proper English your question should say "Have you done your homework? Or Did you do your homework?)
I don't think there is any global english standard regarding ok/cancel and yes/no. It really depends on the context. There are certain contexts where one or the other would make more sense. I things it's perfectly OK to use yes/no if that makes more sense for the kinds of things you are asking.
精彩评论