显示是/否对话框,而不是确定/取消 [英] Show Yes/No-Dialog instead of OK/Cancel
问题描述
我讨厌OK/Cancel(确定/取消)对话框,因为如果我的应用程序询问某人是否确实想做某事,则永远不要用"Cancel"(取消)来回答.
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".
一个小例子:
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();
在本地化中,常量"yes"和"no"是否真的意味着"yes"和"no"?还是我在字符串资源中进行了显式操作,无法使用全局常量.因此,我将两行替换为:
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)
真诚的 xZise
推荐答案
通过Google的快速搜索,发现有几种应用程序可以做到这一点,包括Google自己的我的足迹"应用程序,因此我认为使用android是安全的. R.string.yes.
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.
这篇关于显示是/否对话框,而不是确定/取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!