Binding Data With The AdapterView Class - New
Binding Data With The AdapterView Class - New
THE ADAPTERVIEW
CLASS
Binding Data with the AdapterView Class
• In Android Programming, you can display the stored data using
the AdapterView subclass of the ViewGroup class.
• With the help of the Adapter interface, the AdapterView class
can bind the data to a particular view.
• The data to be displayed using the AdapterView subclass can be
stored in an external resource, such as strings or drawables.
• Some examples of the AdapterView subclasses are ListView,
Spinner, and Gellery, which allow you to bind the stored data
and display the data in a specific manner.
Binding Data with the AdapterView Class
• Firstly, the AdapterView object needs to fill the data in the layout
and then this object is used to retrieve the item selected by the
user.
• Following classes are used to bind and display the stored data:
• ListView
• Spinner
• Gallery
Using the ListView Class
• The ListView class allows you to create the list of items that can be
scrolled by the users.
• You can add the list items to the ListView by using the ListAdapter
interface.
• Firstly, your Activity class should extend the ListActivity class
instead of the Activity class.
• Further, the setListAdapter (ListAdapter) method is being invoked to
add a ListView class to occupy the entire screen of the Activity class.
• The ArrayAdapter class used to manage the array of list of items is
passed as an argument to the setListAdapter() method.
• The array of list of items would be displayed into the ListView class.
Using the ListView Class
Using the ListView Class
Using the ListView Class
Using the Spinner