Skip to content

Instantly share code, notes, and snippets.

@keinix
Created September 21, 2018 06:37
Show Gist options
  • Save keinix/8a9201d1ec7d5fafd6d22fde049afd5c to your computer and use it in GitHub Desktop.
Save keinix/8a9201d1ec7d5fafd6d22fde049afd5c to your computer and use it in GitHub Desktop.
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView;
switch (viewType) {
case Literature.TYPE_BOOK:
itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_layout, parent, false);
return new BookViewHolder(itemView);
case Literature.TYPE_MAGAZINE:
itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_layout, parent, false);
return new MagazineViewHolder(itemView);
default: // TYPE_NEWSPAPER
itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.your_layout, parent, false);
return new NewspaperViewHolder(itemView);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment