我这样更改代码后,无法单击该按钮。在我更改之前,可以单击该按钮。顺便问一下,我的错误在哪里?
代码 :
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
}
}
}
}
});
}
慕的地6264312
相关分类