【发布时间】:2011-09-09 16:52:14
【问题描述】:
所以我在这里搜索了一些关于 AlertDialog 的问题,但我不完全确定我在做什么,所以我很难将这些问题与我自己的示例联系起来。 (我对整个 android 编程还是新手,所以请多多包涵。)
我已经在公共类_下定义了这个Activity实现了OnCLickListener ...
public AlertDialog myAlertDialog;
然后我在 onClick 下有这个
public void onClick(View src) {
switch(src.getId()){
case R.id.buttonOk:
if (score==0){
AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
myAlertDialog.setTitle("Title");
myAlertDialog.setMessage("Message");
myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
myAlertDialog.show();
}
此行及其下一行有错误:
myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
错误:
1st:此行有多个标记 - DialogInterface 无法解析为类型 - 方法 setButton(String, new OnClickListener(){}) 未定义类型
第二个:DialogInterface 无法解析为类型
谁能告诉我我做错了什么?
谢谢!
【问题讨论】:
标签: android android-layout dialog alert android-alertdialog