Android for each loop store value in array
I am working on foreach loop in android(java).
for(Hashtable<String , Strin开发者_运维问答g> tableLang :list)
{
Toast.makeText(this,""+tableLang.get("author"),Toast.DURATION.LONG);//this works
}
I am able to get the values required and print thm or toast thm. But i want to add the authors into a array. so that I can display them in a listView. plz help me
This should work
ArrayList<String> authors = new ArrayList<String>();
for(Hashtable<String , String> tableLang :list)
{
Toast.makeText(this,""+tableLang.get("author"),Toast.DURATION.LONG);//this works
authors.add(tableLang.get("author"));
}
精彩评论