Basically what I want is something like this in kotlin:
public class BindingViewHolder<T extends ViewDataBinding> extends RecyclerView.ViewHolder {}
//it should be:
public class BindingViewHolder<T: ViewDataBinding> :
RecyclerView.ViewHolder() {}
I'm using extending java classes so I don't know if this is possible, Android Studio tell me that the type is expected but neither writing the type inside <> or inside () it works.
The RecyclerView.ViewHolder
constructor
requires an item view passed in:
public RecyclerView.ViewHolder (View itemView)
You have to pass a base class constructor parameter from derived class ie:
class BindingViewHolder<T : ViewDataBinding>(binding:T)
: RecyclerView.ViewHolder(binding.root)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.