ListView is a ViewGroup that creates a list of scrollable
items. The list items are automatically inserted to the list
using a ListAdapter.
Introduction
List View
Introduction
Change extends
public class ListView extends ListActivity {
Introduction
We want to display these names
as our list items
String[] names = {
"Ashley","Ben","Charles","Dean","Elly","Fiona","George","
Hitch","Iris","John","Ken",
"Lily","Matt","Nick","James","Penny","Queen","Richard","S
am","Tom","Vincent",
"Wilson","Noah"
Introduction
Create an ArrayAdapter that will contain all list items
ArrayAdapter<String> adapter;
Assign the name array to that adapter and also
choose a simple layout for the list items
adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,n
ames);
Assign the adapter to this ListActivity
setListAdapter(adapter)
0 comments:
Post a Comment