Android 如何在执行过程中阻止OnCLIKListNER?
我需要在执行过程中退出OnCLICListNER事件,但是找不到这样的命令。尝试使用break,但它只能用于for循环,我正在寻找一个命令,它将停止执行过程,而不是终止或完成活动Android 如何在执行过程中阻止OnCLIKListNER?,android,onclicklistener,android-alertdialog,Android,Onclicklistener,Android Alertdialog,我需要在执行过程中退出OnCLICListNER事件,但是找不到这样的命令。尝试使用break,但它只能用于for循环,我正在寻找一个命令,它将停止执行过程,而不是终止或完成活动 saveBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { amountEntered = (EditText) findView
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
}
});
});
另一个按钮(肯定按钮)将关闭对话框并继续保存
感谢advanced为您提供的时间和帮助。我想您正在寻找
返回声明。它只是从当前方法返回,可能带有一个返回值,但这不是您在这里要查找的内容。只需调用alertDialog。或者alertDialog。我不确定我是否完全遵循了您的意思,但是显示alertDialog
不会停止在saveBtn
的onClick()
方法中执行的其余代码,如果您这样想的话。将显示警报对话框
,无论用户最终单击了什么按钮
,都会立即继续执行saveBtn
的onClick()。您要做的是执行肯定的按钮中的save
onClick()
。