在我这样更改代码后,无法单击该按钮。在我更改之前,可以单击该按钮。顺便问一下,我的错误在哪里?
代码:
buttonNext.setOnClicklistener(new View.OnClicklistener() {
@Override
public void onClick(View v) {
String getBarcode = scanBarcodeEditText.getText().toString().trim();
if (TextUtils.isEmpty(getBarcode)) {
scanBarcodeEditText.setError("Please enter barcode");
} else {
checkBarcode(getBarcode);
}
}
});
private void checkBarcode(final String barcode) {
collectionReference.get().addOnCompleteListener(new OnCompleteListener<Querysnapshot>() {
@Override
public void onComplete(@NonNull Task<Querysnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentsnapshot queryDocumentsnapshot : task.getResult()) {
if (queryDocumentsnapshot.getString("barCode") != null) {
collectionReference.document(queryDocumentsnapshot.getId()).update("productQuantity",FieldValue.increment(1).toString());
// Intent to another activity
} else {
// Intent to another activity
}
}
}
}
});
}