如何在 onClick()
内关闭 Android 中的应用程序?
我的代码如下:
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
System.out.println("cancel clicked");
}
});
alertbox.show();
如果我在onClick
内写入finish()
,它没有帮助。
最佳答案
试试这个方法
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
ActivityName.this.finish();
}
});
alertbox.show();
}
关于android - 如何在Android中单击Alert Box中的按钮时关闭应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7253782/