开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜