kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -




i start using kotlin , defined interface this:

   interface aadapter<vh : recyclerview.viewholder> {          fun oncreateaviewholder(parent: viewgroup): vh          fun onbindaviewholder(v: vh, position: int)     } 

and when try use on code:

class klasa (         private val adapter: aadapter<*> ) {     fun dosth(){       //...        val vh = this.adapter.oncreateaviewholder(parent)       //on below line error       adapter.onbindaviewholder(v, position)      //...   }  } 

i error out-projected type 'aadapter<*>' prohibits use of 'public abstract fun onbindaviewholder(v: t, position: int): unit

i tied add "in" or "out" definition i'm confused.

how allow it.

replace aadapter<*> aadapter<recyclerview.viewholder>.

class klasa (         private val adapter: aadapter<recyclerview.viewholder> ) {  // ... 

because have declared aadapter has type parameter vh type subclass of recyclerview.viewholder. , in class klasa have instance of aadapter has type parameter of type.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -