我想做一個警報對話框,但下面的代碼「setNegativeButton」和「setPositiveButton」變成紅色,那意味着有一些錯誤, 我該怎麼辦? 謝謝!AlertDialog錯誤「PositiveButton」
`enter code here`AlertDialog alertDialog = new AlertDialog.Builder(GameActivity.this).create();
alertDialog.setTitle("Game Over!");
alertDialog.setMessage(" Total time " + String.valueOf(timeSpent));
alertDialog.setPositiveButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.setNegativeButton("Restart", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
請還發布錯誤消息 –