开发者

Android for each loop store value in array

开发者 https://www.devze.com 2023-04-13 04:37 出处:网络
I am working on foreach loop in android(java). for(Hashtable<String , Strin开发者_运维问答g> tableLang :list)

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"));
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号