A simple example of how to implement a list view in Android. You can extends a ListActivity instead of ActionBarActivity
or Activity, but this example extends ActionBarActivity.
What’s in the example?
- A list of strings:
- An ArrayAdapter:
adapter used to connect the data and view
- Item click listener: used to show an item, when it is clicked.
####the following image shows how it looks like.
- create a String list with some items in
- create an ArrayAdapter, add your list in,
android.R.layout.simple_list_item_1 is Android build in.
addItemClickListener(listView) method is used to add listener and implement the react action.
Add flowing code to layout activity :
Source code on Github
comments powered by