I would like to have users enter a last name into a form and automatically provide the user with the last name's account id. The account id is store in a Firebase table. But onEditorAction
won't allow me to paste in the onDataChange
function. The @Override
triggers "Annotations are not allowed here." Any idea how to make onEditorAction
work with onDataChange
?
Here is my failing code:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference ehrRef = rootRef.child("ehr");
mFirstName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_DONE) {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Boolean found;
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String ehrLastName = ds.child("lastNameEHR").getValue(String.class);
found = ehrLastName.contains(mLastName.getText().toString());
if (found) {
mUserIdBackPainHistory.setText(ds.child("userIdEHR").getValue(String.class));
}
}
}
handled = true;
}
return handled;
}
});