What is the difference between ArrayAdapter , BaseAdapter and ListAdapter
Solution 1
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.
Solution 2
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
Kanaiya Katarmal
The girl on the picture has no connection to me (it was randomly selected). This is just a test to see how many people will access my profile. On the 1-st of jan 2017 before posting this picture there were 267 who checked my profile in 4 years and 4 month. Please do not be disappointed with this test, rather up-vote my answers if you like the joke :-).
Updated on August 03, 2020Comments
-
Kanaiya Katarmal almost 4 years
Could you please tell me difference between
ArrayAdapter
,BaseAdapter
andListAdapter
. -
Spinner over 11 yearsYou are correct in saying that
ArrayAdapter
is a concrete class. However,ListAdapter
is not a class, it is an interface implemented byBaseAdapter
. In short, you could either use the ready-madeArrayAdapter
, or write your own adapter that extendsBaseAdapter
. -
Spinner over 11 yearsNote that ListAdapter is an interface, whereas the other two are classes that implement ListAdapter (one indirectly).
-
user1708134 about 11 yearscan you give an instance when will i use base and array adapter?
-
Mina Dahesh about 9 yearsi've question, i want to use DataBase in my proje that fills with users data, and after filling ,all the items will be shown in ListView. but i don't know which of Adapter is usfull for me?ArrayAdapter or BaseAdapter? please help me. thanks
-
Ashwin N Bhanushali about 9 yearsIt should be CursorAdapter please see developer.android.com/reference/android/widget/…