Beginning RecyclerView - Part 5: Challenge: | Ray Wenderlich Videos

Practice what you've learned so far to add more data into the rows of the RecyclerView, and then see a solution.

This is a companion discussion topic for the original entry at

I would like to know what it’s the difference rendering a recycleView using in the adapter the RecyclerView.Adapter and use an extension of BaseAdapter.

For example in this code:

    class MenuFoodAdapter : BaseAdapter {
    var foodsList = ArrayList<Food>()
    var context: Context? = null

    constructor(context: Context, foodsList: ArrayList<Food>) : super() {
        this.context = context
        this.foodsList = foodsList

    override fun getCount(): Int {
        return foodsList.size

    override fun getItem(position: Int): Any {
        return foodsList[position]

    override fun getItemId(position: Int): Long {
        return position.toLong()

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val food = this.foodsList[position]

        var inflator = context!!.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        var foodView = inflator.inflate(R.layout.cell_menu_food, null)
        foodView.cell_menu_food_name_lbl.text =!!
        foodView.cell_menu_food_price_lbl.text = food.price!!

        return foodView


What method it’s recomended, why or when it’s better to use some of those?

Thank you

Thanks for the question, @diegorobh! BaseAdapter is meant to be used with UI elements like ListView and Spinner, while RecyclerView.Adapter is specifically designed to be the adapter for use with RecyclerView. The RecyclerView version enforces the ViewHolder pattern, which will give you better rendering performance in the list. Thanks again!

1 Like