我正在尝试RecylerView
在单个文档中使用附加的图像数据结构填充 Android 中的一个。我想列出每个 ID 的每个名称、地区、图像。
它需要在不破坏子集合的情况下完成。是否有任何可能的智能方法来填充RecylerView
. 谢谢
这是我正在使用的示例数据。[![在此处输入图像描述][1]][1]
编辑1:我尝试实现以下内容,它有效吗?
private void setUpRecyclerView(View view) {
CheckinList = new ArrayList<>();
notebookRef.get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>(){
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) {
user user = documentSnapshot.toObject(user.class);
HashMap<String, HashMap> about = user.getAbout();
for(Map.Entry<String, HashMap> entry : about.entrySet()) {
String key = entry.getKey();
HashMap<String, HashMap> value = entry.getValue();
String Name = "";
String District = "";
String imageUrl = "";
for (Map.Entry<String, HashMap> entry3 : value.entrySet()) {
String key3 = entry3.getKey();
if (key3 == "name"){
Name = entry3.getValue().toString();
} else if (key3 == "district"){
District = entry3.getValue().toString();
} else if (key3 == "imageurl") {
imageUrl = entry3.getValue().toString();
}
}
CheckinList.add(new Checkin(Name, District, imageUrl));
}
}
}
});
adapter = new NoteAdapter(CheckinList, mContext);
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setAdapter(adapter);
}```
full data scheme screenshot
[![enter image description here][2]][2]
[1]: https://i.stack.imgur.com/2Jspj.jpg
[2]: https://i.stack.imgur.com/iwsat.jpg