I have a ListView that is populated with data from my FirebaseData using a query to filter what data is rendered. I was trying to add a search feature to my ListView but no results are displaying. The query works fine to fill the ListView originally but the If Statement doesn't render any results. Here is the block of code relating to the search feature:
private void firebaseGroupSearch(final String groupInfo) {
final String groupNo = editTextGroupNo.getText().toString().trim();
Query orderQuery = databaseGroups.orderByChild("userID").equalTo(user.getUid());
orderQuery.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot groupSnapshot : dataSnapshot.getChildren()) {
Group group = groupSnapshot.getValue(Group.class);
if(group.getGroupNo() == groupNo) {
groups.add(group);
}
}
GroupList groupList = new GroupList(ActivityAllGroups.this, groups);
listViewGroups.setAdapter(groupList);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
}); }
Any suggestions on how to fix this are appreciated!
Aucun commentaire:
Enregistrer un commentaire