Gyroscope
Gyroscope

Reputation: 3151

Android extending Adapter vs extending BaseAdapter

I'm creating a custom ListView that will that will accommodate rows having different layouts (i.e. Headings, and clickable items). Is there any particular difference between my custom adapter class extending Adapter over BaseAdapter? It looks like I need to override the same methods (getItem, getView... ect) in either case. Are there any performance differences? or does one do some of the implementation for you if you call super.method()? I understand that BaseAdapter is a subclass of Adapter, but what extra functionality do you get out of it?

Cheers, Luke.

Upvotes: 1

Views: 711

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006869

It looks like I need to override the same methods (getItem, getView... ect) in either case

You have to implement fewer methods if you inherit from BaseAdapter rather than creating a full implementation of the Adapter interface. For example, BaseAdapter handles registerDataSetObserver() and unregisterDataSetObserver() for you.

Are there any performance differences?

Not usually.

I understand that Adapter is a subclass of BaseAdapter

Absolutely not. Adapter is an interface, not a class. BaseAdapter implements Adapter.

but what extra functionality do you get out of it?

You do not get any "extra functionality" out of Adapter, because Adapter is an interface.

Upvotes: 5

Related Questions