tags:

views:

156

answers:

2

Hello, 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

+1  A: 

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

EboMike
Hmmm okay, but where does your example use android.R.string.yes ? And I don't want to know if it is "save", I only want to know how to rename the buttons to Yes/No using constants named like this. Or if I had to add the values manually. I'm not a native english speaker, but is it common to use Ok/Cancel-Dialogs instead of Yes/No-Dialogs? For me it's sounds ugly to answer "Did you done your homework?" with "OK" or "Cancel". Sincerely xZise
xZise
For me, "did you done your homework" sounds ugly :) It's "Did you do your homework". Just search for "android.R.string.yes" in the link I posted. Actually, it changed, check this link here: http://mytracks.googlecode.com/hg/MyTracks/src/com/google/android/apps/mytracks/io/backup/ExternalFileBackup.java?r=5ebff81c1c25d9600efb5d88eecc3e068ec22ae9
EboMike
And to answer your question - you're absolutely right, "Yes" and "No" would be much more appropriate button names, and you'd do the right thing to change them. Windows even has MB_YESNO as an option for its dialogs. Android doesn't, but your code would do the proper thing.
EboMike
Hmmm okay thanks, I hoped I only miss some constant. Sincerely xZise
xZise
+2  A: 

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.

Mayra