开发者

Creating a ListView layout from an ArrayList

What I want to do in one of my tabs in my application is have a ListView of contacts. Though, in that example, the ListView is made from an array of Strings. Is there a way that I can create one of those using开发者_开发百科 the values from an ArrayList?

Thanks!


Yes you can.

This tutorial explains everything, including how to do the xml files and java files.

http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/


I actually did some more Google'ing of this, and I found this:

String str [] = (String []) neoFriends.toArray (new String [neoFriends.size ()]);

Where neoFriends is the ArrayList<String>.


Yes. Create an ArrayAdapter and pass in the ArrayList in the [constructor][2].

[2]: http://developer.android.com/reference/android/widget/ArrayAdapter.html#ArrayAdapter(android.content.Context, int, T[])

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜