How do you override the void setAdapter(T adapter) method for AutoCompleteTextView?
class CustomAutoCompleteTextView extends AutoCompleteTextView {
//constructors
@Override
public void setAdapter(??? adapter) {
super.setAdapter(adapter);
}
}
I referenced the android dev page for the method signature, but was confused at the generic T. Earlier in the page, it says "T extends ListAdapter & Filterable". I'm not sure how to translate this into the Override signature. I also checked some previous stackoverflow questions (one about a ListView adapter), but it didn't help.
A solution would be nice, but also an explanation on what is going on would also be appreciated.
Thanks!
I think I just figured it out. Go figure, right when you go for help. Here is my answer:
@Override
public <T extends ListAdapter & Filterable> void setAdapter(T adapter) {
super.setAdapter(adapter);
}
Turns out you need to specify that class T (I was getting 'unresolved class T' before).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.