Course Content

Course Content

Adapters and Selection Components

Adapters and Selection components in Android 

 

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.

 

Adapter in Android

 

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.

 

Why Android Adapters?

 

Without Android Adapter, to implement the ListView functionality, you will need to:

  • Create a Text View within a Scroll View group.
  • We will need to implement the Pagination concept.

Why we need Pagination?

 

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.

 

Types of Adapters

 

The most common list adapters are :

  • ArrayAdapters
  • SimpleCursorAdapters
  • CustomAdapters

Base Adapter in Android

 

ArrayAdapter and SimpleCursorAdapters are subclasses of BaseAdapter class.

 

BaseAdapter is an abstract class that implements ListAdapter and SpinnerAdapter interfaces.

 

Array Adapter in Android

 

It can handle data based on Array.

DataSource (ArrayList) <----------> Adapter <-----------> Adapter View (List and Grid view)

 

Simple Cursor Adapter in Android

 

DataSource (Cursor and ArrayList) <----------> Adapter <-----------> Adapter View (List and Grid view)

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
App Store
297K+ Downloads
App Download Section Circle 1
4.5 Rating
App Download Section Circle 2
10K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere