I have multiple classes, which all extend some BasicDataModel:
public class NewsItem extends BasicDataModel
public class PhotosItem extends BasicDataModel
etc. So I need to make ArrayAdapters for all of them, and I wonder if it is possible to make some generic ArrayAdapter to fit all my objects. So far I tried to make
public class MyAdapter extends ArrayAdapter<BasicDataModel>
but as long as I pass ArrayList, for example, this doesn't work.
Thanks in advance
Try
public class MyAdapter<T extends BasicDataModel> extends ArrayAdapter<T>
and use
MyAdapter<NewsItem> news;
I tried Nikita Beloglazov suggestion:
public class MyAdapter<T> extends ArrayAdapter<T extends BasicDataModel>
but found that it wouldn't compile.
Then I tried:
public class MyAdapter<T extends BasicDataModel> extends ArrayAdapter<T>
and that worked just fine :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With