Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class CategoriesAdapter(
private val context: Context,
private val listOfCategories: List<Category>
) : RecyclerView.Adapter<CategoriesAdapter.CategoryViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryViewHolder {
return CategoryViewHolder(
LayoutInflater.from(context).inflate(R.layout.item_category, parent, false)
override fun onBindViewHolder(holder: CategoryViewHolder, position: Int) {
override fun getItemCount(): Int {
return listOfCategories.size
class CategoryViewHolder(
private val view: View
) : RecyclerView.ViewHolder(view) {
fun bind(category: Category) {
view.findViewById<TextView>( =
view.findViewById<RecyclerView>( =
ItemsAdapter(view.context, category.listOfItems)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment