I have this class
public class AdapterListView extends BaseAdapter { }
I got an error if I don’t implement some methods, like getCount()
The error is:
The type AdapterListView must implement the inherited abstract method
Adapter.getCount()
The BaseAdapter class implements ListAdapter and SpinnerAdapter. These interfaces inherites methods from the Adapter interface, but this interface has the following abstract methods:
- getCount ()
- getItem ()
- getItemId ()
- getItemViewType ()
- getView ()
- getViewTypeCount ()
- hasStableIds ()
- isEmpty ()
- registerDataSetObserver ()
- unregisterDataSetObserver ()
See Adapter interface for more details.
But I just implement getCount(), getItem(), getItemId(), getView(). And the compiler does not give this error. Why this happens?
The reason why you don’y need to implement these methods is that they are already implemented in the abstract class
BaseAdapter.See link with source code: BaseAdapter
A class type
abstractcan implement some of the methods and leave some to be implemented for the class that extends it.Regards.