[英]how can i order recyclerview items in firebase by replay timestamps
how can I order my recyclerview items like this 我该如何订购我的recyclerview物品
mDatabaseReference = FirebaseDatabase.getInstance().getReference();
productQuery = mDatabaseReference.child("Blog").orderByChild("replaydate");
"replaydate" is located in Replay>psotkey>replaydate I want order blog items by repaydate, is this possiple? “ replaydate”位于Replay> psotkey> replaydate我想按还款日期订购博客项目,这是可行的吗?
If you want to get the messages by timestamp order you can use 如果要按时间戳顺序获取消息,可以使用
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) {
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.