gpt4 book ai didi

java - android获取HashMap数组的值

转载 作者:行者123 更新时间:2023-11-29 03:40:47 25 4
gpt4 key购买 nike

我试图获取 Hashmap 数组的值,但我获取的是索引/键。

ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();

编码我如何从解析器获取值

 HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
map.put(KEY_LAT, parser.getValue(e, KEY_LAT));
map.put(KEY_LON, parser.getValue(e, KEY_LON));
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
menuItems.add(map);

然后我尝试获取值,但我收到索引。

for (int i = 0; i < menuItems.size(); i++){
int latitude = Integer.parseInt(KEY_LAT);
int longitude = Integer.parseInt(KEY_LON);
itemizedOverlay.addOverlayItem(latitude, longitude, KEY_NAME, makerDefault);
}

如何从 menuItems 数组中获取值?在其他 Activity 中,我获得了值,但通过 TextView 使用了这些值。还有其他办法吗?

最佳答案

试试这个:

for (Map<String, String> menuItem : menuItems) {
int latitude = Integer.parseInt(menuItem.get(KEY_LAT));
int longitude = Integer.parseInt(menuItem.get(KEY_LON));
itemizedOverlay.addOverlayItem(latitude, longitude, KEY_NAME, makerDefault);
}

关于java - android获取HashMap数组的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13250160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com