0
我试图让我的应用程序使用alertdialog箱要么玩另一个游戏(通过点击“是”或退出应用程序退出(通过点击“否”)的Android alertdialog盒 - 从应用程序
。我得到它重置应用程序罚款,但试图添加退出函数('否')时,.setTitle方法突然说'不能解决方法'setTitle(java.lang.String)'
这很好在我添加'.setNegativeButton'之前
任何人都可以看到我做了什么错吗?
谢谢
@Override
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(Task1Activity.this);
alert.setMessage("You have guessed incorrectly three times. " +
"The answer was " + ranNum + ". " + "Would you like to play again?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//dialog.dismiss();
Intent i = new Intent(Task1Activity.this, Task1Activity.class);
startActivity(i);
}
});
alert
.setCancelable(false)
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
};
}
.setTitle("Unlucky!")
.create());
谢谢。就是这样! –
不用担心,不用客气;-) – HomerPlata