Nima Khalili
Nima Khalili

Reputation: 414

RecyclerView is not show last row of list

When I use condition to set text item in my recyclerView Adapter then last row is not shown? I dont know how to do that please help me.

class ShopCategoriesAdapter (var list:List<CategoryModel>) :
    RecyclerView.Adapter<ShopCategoriesAdapter.ViewHolder>() {

    inner class ViewHolder(private val binding: ListItemShopCategoriesBinding) :
        RecyclerView.ViewHolder(binding.root) {
        fun bind(categoryModel: CategoryModel) {
            if (categoryModel.level == 1)
                binding.textViewListItemShopCategoriesCategoryName.text = categoryModel.name
        }
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): ShopCategoriesAdapter.ViewHolder = ViewHolder(
        ListItemShopCategoriesBinding.inflate(
            LayoutInflater.from(parent.context),
            parent,
            false
        )
    )

    override fun onBindViewHolder(holder: ShopCategoriesAdapter.ViewHolder, position: Int) {
        holder.bind(list[position])
    }

    override fun getItemCount(): Int {
        return list.size
    }
}

Upvotes: 0

Views: 40

Answers (1)

Muhammed Duzgun
Muhammed Duzgun

Reputation: 36

check your recyclerview's layout settings. be sure about that the layout of recyclerview is upset to wrap content. i have already seen this problem before. and in this problem the solution is not about the adapter, it's releated with layout settings.

Upvotes: 0

Related Questions