Lab 06 - Lists

LISTS

In android, an adapter is a bridge between UI component and data source that helps us to fill data in the UI component. It holds the data and send the data to adapter view then view can takes the data from the adapter view and shows the data on different views like as list view, grid view, spinner etc

BaseAdapter methods:
1. getCount(): The getCount() function returns the total number of items to be displayed in a list. It counts the value from array list size() method or an array’s length.

2. getView(int i, View view, ViewGroup viewGroup): This function is automatically called when the list item view is ready to be displayed or about to be displayed. In this function we set the layout for list items using LayoutInflater class and then add the data to the views like ImageView, TextView etc

3. getItem(int i): This function is used to Get the data item associated with the specified position in the data set to obtain the corresponding data of the specific location in the collection of data items.

4. getItemId(int i): As for the getItemId (int position), it returns the corresponding to the position item ID. The function returns a long value of item position to the adapter.

Exercises

Create a new project and follow the next tutorial http://abhiandroid.com/ui/baseadapter-tutorial-example.html.

dapm/laboratoare/05.txt · Last modified: 2021/04/10 21:03 by ioana_maria.culic
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0