1
I have the following Arraylist:
ArrayList<HashMap<String, String>> menuItens = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < 6; i++){
HashMap<String,String> hashMap = new HashMap<String,String>();
hashMap.put("chave_" + i, "valor_" + i);
}
menuItens.add(hashMap);
Now, in the Class extending to Basedapter I intend to capture the ArrayList<HashMap<String, String>>
the two values "key" and "value" to apply to a Listview.
How best to capture these two values (key and value) in order to add them in two Strings?
Dude, taking a quick look at your code, I didn’t understand two things. The first is, you really need a
ArrayList
? Not enough aHasMap
, since it supports more than one element within it. The second is if this code is running correctly, since you only add the element after thefor
, which would add only one element in theArrayList
...– Felipe Avelar
Hello Philip! I need an Arraylist because each Hasmap Object will have different values. While waiting for help, I described on the Internet the following way to capture the Hasmap values in Arraylist and that solved my problem: <code>String str1 = arrayList.get(position). get("chave_" + position)</code>
– Vitor Mendanha