Download the New LearnVern Android App and enter Lucky Draw to win Free Certificate
Now we will see how we can make the user interface more interesting in our application. This means that what kind of layout we will use in our application, due to which it will be more effective and more user friendly.
We use different types of views in our application such as list view, grid view, action bar, toolbar. So for coding of all these, we will have a requirement of Adapters. So what is this adapter?
We can tell the adapter is used as a bridge, the bridge acts between the adapter view and the UI, it establishes a connection between them, this is what an adapter does.
In simple language, a bridge between the data source (cursor, array list) and adapter view (list view, grid view, spinner) is called an adapter. For example, contact list.
Without Android Adapter, to implement the ListView functionality, you will need to:
Suppose we have more data that exceeds the screen and we can view only 10 at a time then we can scroll to the next set of data. If you don't do pagination it will really be appropriate to retrieve the data again and to store the things sequentially.
So that is why we need an adapter and this can reduce a lot of work and it will be comparatively easy.
The most common list adapters are :
ArrayAdapter and SimpleCursorAdapters are subclasses of BaseAdapter class.
BaseAdapter is an abstract class that implements ListAdapter and SpinnerAdapter interfaces.
It can handle data based on Array.
DataSource (ArrayList) <----------> Adapter <-----------> Adapter View (List and Grid view)
DataSource (Cursor and ArrayList) <----------> Adapter <-----------> Adapter View (List and Grid view)
Have a friend to whom you would want to share this course?