Skip to content

Instantly share code, notes, and snippets.

@keinix
Last active September 21, 2018 06:44
Show Gist options
  • Save keinix/58d2ceaa0e087db40d508ec1311350b2 to your computer and use it in GitHub Desktop.
Save keinix/58d2ceaa0e087db40d508ec1311350b2 to your computer and use it in GitHub Desktop.
public class LiteratureAdapter extends RecyclerView.Adapter {
...
class BookViewHolder extends RecyclerView.ViewHolder {
public BookViewHolder(View itemView) {
super(itemView);
// get reference to views
// itemView.findViewById...
}
void bindView(int position) {
Book book = (Book) mLiteratureList.get(position);
// bind data to the views
// textView.setText()...
}
}
class MagazineViewHolder extends RecyclerView.ViewHolder {
public MagazineViewHolder(View itemView) {
super(itemView);
// get reference to views
}
void bindView(int position) {
Magazine magazine = (Magazine) mLiteratureList.get(position);
// bind data to the views
}
}
class NewspaperViewHolder extends RecyclerView.ViewHolder {
public NewspaperViewHolder(View itemView) {
super(itemView);
// get reference to views
}
void bindView(int position) {
Newspaper newspaper = (Newspaper) mLiteratureList.get(position);
// bind data to the views
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment