I'm looking for a way to implement a simple list view scrolling in my Firebase app, but I am not getting any way out how to implement this. I have already tried 2-3 tutorials and documentation available on the Internet, but didn't the required result.
In my app I want scrolling like at starting first 10 list items load then each time on scrolling next 10 or 20 items will load until the last item appears at the bottom of the list.
So I tried retrieving first 10 items the following way :
ArrayList<Event> event=new ArrayList<>();
Dbref = FirebaseDatabase.getInstance().getReference("/event");
Dbref.startAt(1).limitToLast(10).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
Log.e("Events.java ", "range query started! : " + dataSnapshot.getChildrenCount());
String event_id = snapshot.child("details").child("event_id").getValue().toString();
e=new Event(event_id); //Event is a model class for list items
event.add(e);
Log.e("ShowEventInfo : ", "" + event_id);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
adapter=new Event_CustomAdapter(getActivity(),event);
ls.setAdapter(adapter); //here ls is instance of ListView
I referred this Youtube Video to implement this feature: (https://www.youtube.com/watch?annotation_id=annotation_3916642001&feature=iv&src_vid=YMJSBHAZsso&v=XwIKb_f0Y_w)
In the above code, as you can see I am generating Log to check if data is fetched from the firebase, but I got no output Android monitor.
I have no idea how can I implement Firebase Scrolling in my list view. I think this is a common problem for those who implement infinite-scroll in recycler view/ list view.
Could you please help me implementing this feature. Thanks.