Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ArrayAdapter , BaseAdapter and ListAdapter

Could you please tell me difference between ArrayAdapter , BaseAdapter and ListAdapter.

like image 402
Kanaiya Katarmal Avatar asked Jul 24 '12 10:07

Kanaiya Katarmal


People also ask

What is the difference between ArrayAdapter and BaseAdapter?

Here is the difference: BaseAdapter is a very generic adapter that allows you to do pretty much whatever you want. However, you have to do a bit more coding yourself to get it working. ArrayAdapter is a more complete implementation that works well for data in arrays or ArrayList s.

What is ArrayAdapter used for?

You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data objects you provide, and can be used with list-based user interface widgets such as ListView or Spinner .

What is base adapter?

BaseAdapter, as it's name implies, is the base class for so many concrete adapter implementations on Android. It is abstract and therefore, cannot be directly instantiated. If your data source is an ArrayList or array, we can also use the ArrayAdapter construct as an alternative.

Which one is from BaseAdapter class method?

Base Adapter is common base class of a general implementation of an Adapter. It generally used in ListView, GridView, Spinner etc. Base Adapter extends an object class and implement ListAdapter and SpinnerAdapter. Lets understand it by Coding, how it works and which methods are overrided by it.


2 Answers

BaseAdapter as the name suggests, is a base class for all the adapters.

When you are extending the Base adapter class you need to implement all the methods like getCount(), getId() etc.

ArrayAdapter is a class which can work with array of data. You need to override only getview() method.

ListAdapter is a an interface implemented by concrete adapter classes.

BaseAdapter is an abstract class whereas ArrayAdapter and ListAdapter are the concrete classes.

ArrayAdapter and ListAdapter classes are developed since in general we deal with the array data sets and list data sets.

like image 155
Ashwin N Bhanushali Avatar answered Sep 19 '22 19:09

Ashwin N Bhanushali


ListAdapter

It is an interface that extended Adapter which is the bridge between a ListView and the data that backs the list.

BaseAdaper

Common base class of common implementation for an Adapter that can be used in both ListView (by implementing the specialized ListAdapter interface} and Spinner (by implementing the specialized SpinnerAdapter interface.

ArrayAdapter

A concrete BaseAdapter that is backed by an array of arbitrary objects.

Refer below links

  1. ListAdapter

  2. BaseAdapter

  3. ArrayAdapter

like image 42
Nirali Avatar answered Sep 23 '22 19:09

Nirali