Reputation: 391
I want to create my own ArrayAdapter calling just the super constructor that has only 2 parameters, the context and the resource layout id. The problem is that the getView method is never called if I use that constructor, but if I use the other constructors were I pass a List object parameter or an array, it will call my getView method. I tried to override the isEmpty method and still nothing, also this method is not called either.
Is there any way to make sure the getView method is called just using the super constructor with 2 parameters (context and resource layout id) ?
Thank you.
Upvotes: 2
Views: 774
Reputation: 39191
Since you're not passing a List to the super class when using the two-parameter constructor, you'll need to override the getCount()
method to return the size of your List. Otherwise, the AdapterView will think there are zero items, and will not attempt to call getView()
. For example:
@Override
public int getCount()
{
return list.size();
}
Upvotes: 4