Kotlin One type argument expected for class for abstract generic view holder

后端 未结 2 1879
遇见更好的自我
遇见更好的自我 2020-12-30 21:55

I\'m trying to create a RecyclerView.Adapter with the following:


View holders - Provided the abstract parent and one son

abstract class Base         


        
2条回答
  •  借酒劲吻你
    2020-12-30 22:36

    1- If you use always SettingTitleViewHolder;

    RecyclerView.Adapter
    

    2- If you want to use any class which extended BaseSettingViewHolder;

    RecyclerView.Adapter>
    

    3- Use Any Object Type

    RecyclerView.Adapter>
    

    4- Use extended type parameter for adapter class

    class SettingsMenuAdapter:RecyclerView.Adapter where : BaseSettingViewHolder<*>
    

    5- Define out for abstract class type parameter.

    abstract class BaseSettingsViewHolder RecyclerView.Adapter>
    

    7- Read that article => "Generics in Kotlin" ;)

提交回复
热议问题