eriX
eriX

Reputation: 41

How to display List<> using ListView?

When I use ListView to display a array of my object, I can use the following code:

MyObject[] myObject;
...  
ArrayAdapter<MyObject> itemList = new ArrayAdapter<MyObject>(this, R.layout.list, myObject);   
setListAdapter(itemList);

In case that the input is a list:

List<MyObject> myobject;

How can I assign it to ListAdapter? Please advise, Thx!

Upvotes: 0

Views: 1102

Answers (2)

anon
anon

Reputation:

Even the question seems already to be answered, i'd like to mention using custom listviews with a custom adapter:

There is a great tutorial how to use a listview

http://developerlife.com/tutorials/?p=327

a second tutorial (in 6 parts) you can find here:

http://www.androidguys.com/2008/07/14/fancy-listviews-part-one/

Upvotes: 0

Cheryl Simon
Cheryl Simon

Reputation: 46844

There is another constructor for ArrayAdapter that takes in a list:

ArrayAdapter(Context context, int textViewResourceId, List<T> objects)

See ArrayAdapter java doc for a complete list!

Upvotes: 1

Related Questions