I have a number of custom objects that are significantly different from each other. These objects are stored in different lists and are to be displayed in different ListViews. Because of the design of these ListViews, I need to create my own custom ArrayAdapter. The thing is, the ListView design is supposed to be the same for all ListViews regardless of the objects in the list.
To accomplish this I created an ArrayAdapter for every type of object. E.g. for a custom object coA I made an ArrayAdapter coAAdapter, and for custom object coB I made an ArrayAdapter coBAdapter. This seems very unnecessary to me, since there are next to no difference between these adapters except what kind of ArrayAdapter the custom adapters extends and their constructors:
Adapter for class CoA:
public class CoAAdapter extends ArrayAdapter<CoA> {
public CoAAdapter (Context context, int resource, List<CoA> objects) {...}
}
Adapter for class CoB:
public class CoBAdapter extends ArrayAdapter<CoB> {
public CoBAdapter (Context context, int resource, List<CoB> objects) {...}
}
Is this how custom ArrayAdapters are supposed to be used, or is there a way to make this design a lot simpler, like having one custom ArrayAdapter for all custom objects?
I have thought about some different solutions, like creating a generic custom adapter or using inheritance by creating a common base class for my custom objects, but after some research none of these seems like a good approach.