我如何订购这样的recyclerview物品
mDatabaseReference = FirebaseDatabase.getInstance().getReference();
productQuery = mDatabaseReference.child("Blog").orderByChild("replaydate");
“重播日期”位于Replay> psotkey>重播日期我想按还款日期订购博客项目,这可能吗?
答案 0 :(得分:0)
如果要按时间戳顺序获取消息,可以使用
database.orderByChild("replydate").limitToLast(10)
.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
if (dataSnapshot.getValue() != null) {
Model newModel = dataSnapshot.getValue(Model.class);
//Model is you model which you are using for showing data in recyclerview
arraylist.add(newModel);
adapter.notifyDatasetChanged();
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});