Android - ListView
Objective #1: Use a ListView.
- A ListView is like an array since it isused to display a collection of different items in a scrollable format. ListView's are used in many Android apps.
- Like elements in an array, each item that is placed into a list has a different index position. They start their indexes at 0.
- Android makes it easy to view large lists by incorporating a scroll view in with a ListView.
- Unlike a linear layout, a ListView is a good way to allow a user to manage his/her options and preferences in an app. Also, a ListView is useful for listing options or information of a game or choosing a level of a game for example.
- ListViews cannot be used to store buttons.
- In order to use ListViews in a project, you need to import the ListView class with the statement import android.widget.ListView
- In order to program a ListView, you have to extend ListActivity instead of Activity. A ListActivity is an activity that displays a list of items by binding the activity to a data source such as an array or Cursor and exposes event handlers when the user selects an item. By extending ListActivity, the programmer can use the majority of the methods inside ListActivity that are otherwise not included in the normal Activity class.
- Use the setListAdapter method to create a ListView.
- The method setTextFilterEnabled(true) allows the user to search for their item in the list and it will eliminate those items that do not match. This method is usually enabled prior to enabling it.
- See this link for more info on ListView, review the following tutorials: