Answer the question
In order to leave comments, you need to log in
How to declare a Generic class variable without knowing its type?
There is an abstract class
public abstract class Adapter<T> {
public abstract T onCreateViewHolder(ViewGroup parent);
public abstract void onBindViewHolder(T holder, int position);
public abstract int getItemCount();
}
public class AdapterAudioList: Adapter<VListView> {
PlayList list;
public AdapterAudioList(PlayList list){
this.list = list;
}
public override VListView onCreateViewHolder(ViewGroup parent) {
return new VListView();
}
public override void onBindViewHolder(VListView holder, int position) {
holder.setLabel(list.getAudio(position).artist);
holder.setLabel2(list.getAudio(position).title);
}
public override int getItemCount() {
return 500;
}
}
AdapterAudioList listx = new AdapterAudioList(list);
recyclerView1.setAdapter(listx);
private Adapter adapter;
public void setAdapter(Adapter adb) {
adapter = adb;
}
public abstract class BaseElement :UserControl {}
public abstract class Adapter<T>:BaseElement {
public abstract T onCreateViewHolder(ViewGroup parent);
public abstract void onBindViewHolder(T holder, int position);
public abstract int getItemCount();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question