如何将hashMap数据作为列表检索并显示在列表中

时间:2022-09-14 00:08:04

I am saving date to firebase with HashMap, I watched many tutorials, but facing problem in getting that data into list and display as List. Any help please thanks.

我使用HashMap将日期保存到firebase,我观看了很多教程,但是在将数据导入列表并显示为List时面临问题。任何帮助,谢谢。

2 个解决方案

#1


0  

pretty much you are gonna traversal hashMap and add the useful data in to a arrayList

你几乎要遍历hashMap并将有用的数据添加到arrayList中

#2


0  

To solve your problem i recomand you iterate your Map. You can achieve this using this code:

为了解决您的问题,我重新尝试迭代您的地图。您可以使用以下代码实现此目的:

Map<String, String> map = (Map<String, String>) dataSnapshot.child("yourChild").getValue();
List<String> list = new ArrayList<>();
for (Map.Entry<String, String> entry : map.entrySet()) {
    list.add(entry.getKey() + "/" + entry.getValue());
}

for(String s : list) {
    Log.d("TAG", s);
}

Hope it helps.

希望能帮助到你。

#1


0  

pretty much you are gonna traversal hashMap and add the useful data in to a arrayList

你几乎要遍历hashMap并将有用的数据添加到arrayList中

#2


0  

To solve your problem i recomand you iterate your Map. You can achieve this using this code:

为了解决您的问题,我重新尝试迭代您的地图。您可以使用以下代码实现此目的:

Map<String, String> map = (Map<String, String>) dataSnapshot.child("yourChild").getValue();
List<String> list = new ArrayList<>();
for (Map.Entry<String, String> entry : map.entrySet()) {
    list.add(entry.getKey() + "/" + entry.getValue());
}

for(String s : list) {
    Log.d("TAG", s);
}

Hope it helps.

希望能帮助到你。