Hi I have something like this where my RecyclerVie...
# android
l
Hi I have something like this where my RecyclerViewHolder delegates the creation of the layout to this adapter, is there a way where I can use
LayoutContainer
here in order get cached synthetic views? I Can't find a way to work 😕 LayoutContainer requires the
containerView
initialized at the class initialization but there's no way I can get it on the delegate initialization, only on the
bindView
Copy code
class HeadlineDelegateAdapter @Inject constructor() : BaseDelegateAdapter {

    override fun getLayoutRes(): Int = R.layout.item_dashboard_transaction_headline
    override fun bindView(itemView: View, item: BaseViewType, viewHolder: RecyclerView.ViewHolder) {
        if (item is Headline) {
            tvHeadline.text = item.description
            tvSubtotal.text = item.subtotal
        }
    }
}
@kenkyee Even though I think the subject belongs to this is slack since its about Kotlin Synthetics not being aware of classes that extends classes implementing LayoutContainer I've created a question on SO https://stackoverflow.com/questions/53538375/how-to-make-use-of-kotlin-synthetics-layoutcontainer-on-a-class-that-extends-vie But if this question about kotlin-android-extensions behavior not acting like I was expecting/understood doesn't belong to this slack or kotlin-android channel I don't know actually what really can be discussed here.
k
Kotlixx synth views don't work that great in recycler views IIRC. I think that's what you're hitting. I've seen quirky behavior with them when uses in callbacks too so I don't recommend using them.
l
databinding then?
k
Yep but even that's a pain in viewholders. There are usually so few views in a viewholder that I just do findviewbyid.