如果您不想通过自定义警报对话框执行此操作,请使用此代码
AlertDialog.Builder 生成器;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
builder = new AlertDialog.Builder(this);
//builder.setMessage("Do you want to Exit Scramble?")
builder.setCancelable(false)
.setIcon(R.drawable.sly)
.setTitle(" ")
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int id) {
finish();
}
});
builder.show();
}
假设如果你不想有 OK 按钮,你肯定需要去自定义警报对话框。它很简单。参考这个网站: http ://www.mkyong.com/android/android-custom-dialog-example/