我有一个像这样的 Firestore 数据库:
我想访问每个不同的症状数据,即“Anxiety_data”及其由时间戳组成的子项,然后是字典,并将它们放入RecyclerView使用中FirebaseUI FirebaseRecyclerViewAdapter
我有这个模型类:
public class EntryDataModel {
private String timestamp, symptom, severity, comment;
public EntryDataModel() {}
public EntryDataModel(String timestamp, String symptom, String severity, String comment) {
this.timestamp = timestamp;
this.symptom = symptom;
this.severity = severity;
this.comment = comment;
}
public String getTimestamp() {return timestamp;}
public String getSymptom() {return symptom;}
public String getSeverity() {return severity;}
public String getComment() {return comment;}
}
这是我的Query:
Query query = db.collection("users").document(user_id).collection("symptom_data");
这是Firebase RecyclerView Adapter:
void fireStoreRecyclerAdapterSetup() {
FirestoreRecyclerOptions<EntryDataModel> options = new FirestoreRecyclerOptions.Builder<EntryDataModel>()
.setQuery(query, EntryDataModel.class)
.build();
FirestoreRecyclerAdapter adapter = new FirestoreRecyclerAdapter<EntryDataModel, EntryDataHolder>(options) {
@Override
public void onBindViewHolder(EntryDataHolder holder, int position, EntryDataModel model) {
// Bind the Chat object to the ChatHolder
// ...
System.out.println("Query: " + query.toString());
}
}
}
我不确定我应该如何设置它,以便我从每个症状数据字段中获取所有时间戳数组,并将它们全部放在一个列表中,我可以将其用于recyclerView.
也许我不能使用 FirebaseUI Recycler 适配器,或者我需要先遍历每个不同的症状字段并构建 + 附加一个列表?希望我清楚我想做什么谢谢。
隔江千里
相关分类