我需要在执行过程中退出 OnClickListner 事件,但是找不到执行此操作的命令。尝试使用break,但只能在for循环上使用,我正在寻找一个仅停止执行过程而不终止或完成 Activity 的命令。
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
amountEntered = (EditText) findViewById(R.id.amountEntered);
Integer bal = Integer.parseInt(custBal);
Integer enteredAmount = Integer.parseInt(amountEntered.getText().toString());
// check if amount entered is more than the balance:
if( enteredAmount > bal ){
final AlertDialog.Builder alertDialog = new AlertDialog.Builder(MakePaymentActivity.this,R.style.MyAlertDialogStyle);
alertDialog.setTitle("VERIFY AMOUNT");
alertDialog.setMessage("Is entered amount correct?");
alertDialog.setNegativeButton("NO",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Simply Exit here
}
}
);
});
另一个按钮(积极按钮)只会关闭对话框并继续保存。
最佳答案
关于android - 如何在执行过程中停止 OnClickListener?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43301696/