Hi please help! i have listview and the data frome Firebase and i want to add search bar or searchView to get names Movies frome data firebase
Asked
Active
Viewed 705 times
0

ReyAnthonyRenacia
- 17,219
- 5
- 37
- 56

mouad zizi
- 307
- 2
- 9
-
When searching for a name All data with the same name appear in the list – mouad zizi Jul 11 '18 at 11:53
2 Answers
0
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();
DatabaseReference query = mDatabase.child("Movies");
query.orderByChild("name").startAt(searchText);
query.addListenerForSingleValueEvent(
new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot messageSnapshot: dataSnapshot.getChildren()) {
String name = (String) messageSnapshot.child("name").getValue();
Log.d("TAG", "name is :"+name);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});

Vinay Rathod
- 1,262
- 1
- 10
- 19
-
-
you can log your data in `onDataChange`, please check my updated answer... for showing data in list you have to set that – Vinay Rathod Jul 11 '18 at 12:50
-
i don't have any idea how can i sett data Which has been brought in listview – mouad zizi Jul 11 '18 at 12:56
-
you can follow some blog for that https://www.mytrendin.com/receive-data-firebase-display-recyclerview-android/ – Vinay Rathod Jul 11 '18 at 12:57
0
To solve this, you need to use a query that looks like this:
DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
Query query = rootRef.child("Movies").orderByChild("name").startAt(name).endAt(name + "\uf8ff");
query.addListenerForSingleValueEvent(/* ... */);

Alex Mamo
- 130,605
- 17
- 163
- 193
-
Stack Overflow is not a place where you can find people who can write code for you. You should make your own attempt given the information in the answer, and ask another question if something else comes up. – Alex Mamo Jul 11 '18 at 12:26
-
how can i sett the data Which has been brought in list https://a.top4top.net/p_922wxzoj1.png – mouad zizi Jul 11 '18 at 12:31
-
-
i don't have any idea how can i sett data Which has been brought in listview – mouad zizi Jul 11 '18 at 12:50
-
Take a look **[here](https://stackoverflow.com/questions/48622480/showing-firebase-data-in-listview)**. – Alex Mamo Jul 11 '18 at 13:40
-
What works? To display the data in the ListView, use the code specified in that answer, right? – Alex Mamo Jul 12 '18 at 07:59
-