【发布时间】:2015-06-09 17:48:57
【问题描述】:
我试图弄清楚当我按下负/正按钮时如何明确禁用警报对话框。我当前的应用程序可以点击屏幕,我希望我的应用程序在第一次点击时显示一个警报对话框。这个盒子说“注意,有些名字是发明的!”按钮是“确定!”(正面按钮)和“不要提醒我”(负面按钮)。在这两种情况下,我都希望应用程序在每次点击时停止显示 Box,因为这显然令人沮丧,并且在每次点击时显示一条消息毫无意义(考虑用户每 5 秒点击 1 或 2 次)。所以我想弄清楚如何在第一次点击后禁用它。
暂时,这是我写的
public void tap(View view) {
final AlertDialog.Builder tapAlert = new AlertDialog.Builder(this);
tapAlert.setMessage("The names are mostly invented!");
tapAlert.setPositiveButton("Ok!", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
tapAlert.setNegativeButton("Don't remind it to me", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
tapAlert.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
// do nothing, just allow dialog to close
// this happens on back button getting hit
}
});
tapAlert.setTitle("Attention!");
tapAlert.create();
tapAlert.show();
【问题讨论】:
-
java != javascript ftfy