I have a hashmap and an iterator that iterates through four alternatives and the corresponding value to a question. I have a TableLyaout where a TableRow is added programmatically depending on how many rows there are.
I get it to print a random alternative, but only the one. How can I get all four alternatives to get written in a textview each?
Iterator<Entry<String, Integer>> entries = map.entrySet().iterator();
while (entries.hasNext()) {
Entry<String, Integer> entry = entries.next();
String alternative = entry.getKey();
Integer value = entry.getValue();
try {
alternative = new String(alternative.getBytes("macintosh"), "UTF-8");}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
mTvAlt.setText(alternative +" "+value);}
I found the solution.
I would have preferred to get the value as an integer array, but didn’t know how so I took it as a string array.