How do we add generic class as Map value ? I am d...
# getting-started
a
How do we add generic class as Map value ? I am defining class named
Copy code
abstract class CardHolder<T:RecyclerView.ViewHolder>{

    lateinit var actionListener: CardActionListener

    abstract fun onCreateViewHolder(parent: ViewGroup): T

    abstract fun onBindViewHolder(holder:T, card: Card, position: Int)
}
which will be extended to do inflationa and other formalities to display data,
Copy code
class NewCardDelegate:CardViewHolder<NewHolder>{
	//Rest of code
}
the reason I was doing this so that I could define a mutableMap<Int,CardHolder> and reduce the Adapter class
Copy code
val map =mutableMapOf<Int,CardHolder>
map[25] = NewCard() //error
but it seems like its not right way Please guide me for any other better way
k
You need
CardHolder<*>
as the map value type.
a
ooh what is this term called @karelpeeters
*