By default the ArrayAdapter
creates a view for each array item by calling toString()
on each item and placing the contents in a TextView
.
Example:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, myStringArray);
where android.R.layout.simple_list_item_1
is the layout that contains a TextView
for each string in the array.
Then simply call setAdapter()
on your ListView
:
ListView listView = (ListView) findViewById(R.id.listview);
listView.setAdapter(adapter);
To use something other than TextViews for the array display, for instance, ImageViews, or to have some of data besides toString()
results fill the views, override getView(int, View, ViewGroup)
to return the type of view you want. Check this example.