I have a hashtable filled with data, but I don't know the keys How can I loop througth a HashTable keys in android? I'm trying this, but it doesnt work:
Hashtable output=new Hashtable();
output.put("pos1","1");
output.put("pos2","2");
output.put("pos3","3");
ArrayList<String> mykeys=(ArrayList<String>)output.keys();
for (int i=0;i< mykeys.size();i++){
txt.append("\n"+mykeys.get(i));
}
Use enumeration to traverse over all the values in the table. Probably this is what you would want to do:
Enumeration e = output.keys();
while (e.hasMoreElements()) {
Integer i = (Integer) e.nextElement();
txt.append("\n"+output.get(i));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With