【发布时间】:2018-07-22 14:43:27
【问题描述】:
我已将日期保存为密钥。现在我想将日期检索到列表视图。我知道如何将子值检索到列表视图,但不确定如何对键值执行相同操作。以下是我正在使用的代码:
databaseReference = FirebaseDatabase.getInstance().getReference().child(savedCollname).
child("Students").child(userId).child("Lectures").child(post_key);
FirebaseListOptions<String> options = new FirebaseListOptions.Builder<String>()
.setLayout(R.layout.subject_list_heading)
.setQuery(databaseReference, String.class)
.build();
adapter = new FirebaseListAdapter<String>(options) {
@Override
protected void populateView(View v, String model, int position) {
TextView subject_name = v.findViewById(R.id.tv_sub_heading);
subject_name.setText(model);
}
};
list_of_date.setAdapter(adapter);
我的应用程序因错误而崩溃:Failed to convert value of type java.util.Hashmap to String
数据库的JSON对象:
{
"-LHSdSCzD_tZhzqvSOw_" : {
"17-7-2018" : {
"Absent" : "0",
"Present" : "1",
"Total_Lectures" : "1"
},
"18-7-2018" : {
"Absent" : "0",
"Present" : "1",
"Total_Lectures" : "1"
}
}
我想检索日期,即列表视图的节点。 如果有其他方法请提及。任何帮助表示赞赏。
【问题讨论】:
标签: android firebase-realtime-database firebaseui