我正在使用下面的代码通过firebase recyclerview检索我的数据库中的数据 . 我能够检索所有数据但是它们一次被检索 . 我希望一次检索少量数据,并且当用户需要加载更多数据时向上滚动 . 我怎么去了?
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot){
if(dataSnapshot.child("Male").hasChild(user_id)){
query = databaseReference1.child("Female").orderByChild("halls").equalTo(halls2);
query.keepSynced(true);
}
else{
query = databaseReference1.child("Male").orderByChild("halls").equalTo(halls1);
query.keepSynced(true);
}
FirebaseRecyclerAdapter firebaseRecyclerAdapter = new FirebaseRecyclerAdapter(
User.class, R.layout.users_row, tab1.UserViewholder.class, query) {
@Override
protected void populateViewHolder(tab1.UserViewholder viewHolder, User model, int position) {
final String postUser_id = getRef(position).getKey();
Log.v("key",postUser_id);
//postUserId = postkey of card
final String user_id = firebaseAuth.getCurrentUser().getUid();
//final Match match = new Match(username, downloadUrl );
viewHolder.setUsername(model.getUsername());
viewHolder.setLevels(model.getLevels());
viewHolder.setDownloadUrl(getActivity().getApplicationContext(), model.getDownloadUrl());
}
};
users2.setAdapter(firebaseRecyclerAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError){
}
});