如何在警报框中添加一个功能意味着我创建了一个Tic Tac Toe游戏inriod问题是当一个玩家赢了游戏时出现一个警告框并且如果他点击是那则问“想再玩”然后游戏再次播放但在警告框中我没有再次运行该功能
答案 0 :(得分:0)
此代码将解决您的问题。
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Unable to Access Camera, Face Unlock will not work!")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
**//write your code here in case of OK**
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
**//write your code here in case of user press cancel**
}
});
AlertDialog alert = builder.create();
alert.show();