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