检查下面的代码:String jsonString = writer.toString();
JSONObject jsonObj = new JSONObject(jsonString);
defaultCurrencyValue = jsonObj.getString(DefaultCurrencyKey);
currenciesTypes = jsonObj.get(CurrenciesKey);当我使用 Debugger,获取 curenciesType 对象类变量中的值currenciesTypes JSONObject (id=830084916104)
myHashMap HashMap (id=830084916120)
[0] HashMap$HashMapEntry (id=830084916440)
key "PKR" (id=830084916256)
value "Rs" (id=830084916368)
[1] HashMap$HashMapEntry (id=830084917208)
key "EUR" (id=830084917064)
value "€" (id=830084917176)
[2] HashMap$HashMapEntry (id=830084916696)
[3] HashMap$HashMapEntry (id=830084916952)如何在两个数组列表中保存 key 和它的值?
2 回答
慕容森
TA贡献1853条经验 获得超18个赞
有两个 arraylists 申明 keys,和 values:
String jsonString = writer.toString(); JSONObject jsonObj = new JSONObject(jsonString); currenciesTypes = jsonObj.get(CurrenciesKey); ArrayList<String> keys=new ArrayList<String>(); ArrayList<String> values=new ArrayList<String>(); Iterator<String> iterator=currencyType.keys(); while(iterator.hasNext()) { String key=iterator.next(); keys.add(key); values.add(currencyType.get(key)); }
RISEBY
TA贡献1856条经验 获得超5个赞
用
private static List<Map<String, String>> mListItems = new ArrayList<Map<String,String>>();
添加回答
举报
0/150
提交
取消