-2

I'm learning Android development, while following a tutorial made by Lets Build this App ( on Youtube ). He used this library and I tried too, but I'm failing. I created a RecyclerView and tried to make a GroupAdapter using Groupie like this:

newmessage_view.adapter = groupAdapter

This is what he does in the video, but when I do it, it gives me an error:

Type mismatch.
Required:
(RecyclerView.Adapter<android.support.v7.widget.RecyclerView.ViewHolder!>?..RecyclerView.Adapter<*>?)
Found:
GroupAdapter<com.xwray.groupie.ViewHolder>

I hope someone can help me.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Bruno Dias
  • 13
  • 1
  • 4

5 Answers5

4

In the new version of Groupie, you need to do as follows

    val adaptor = GroupAdapter<GroupieViewHolder>()

and make sure to add

    import com.xwray.groupie.kotlinandroidextensions.GroupieViewHolder
Nawaraj Bista
  • 326
  • 4
  • 12
3

If you were using the newest version 2.3.0, change to 2.1.0. It works just fine!

AndrinoG
  • 71
  • 1
  • 8
1

If you are using Kotlin you need to create adapter this way

val adapter = GroupAdapter<ViewHolder>()
Valgaal
  • 896
  • 10
  • 25
1

Well i was also following same tutorial and was facing same issue but i resolved by replacing Recycler.Viewholder to GroupieViewHolder.

0

For me I needed to:

val adapter = GroupAdapter<GroupieViewHolder>()

AND remember to override createViewHolder if using the groupie legacy approach

class MyItem(...) : Item<MyItem.MyViewHolder>() {
    ...
    override fun createViewHolder(itemView: View) = MyViewHolder(itemView)
    ...
    class MyViewHolder(view: View) : GroupieViewHolder(view) {
        // Bind Views
    }
}
Gary McGowan
  • 1,641
  • 15
  • 12