Reputation: 353
How to define Livedata genneric with type List ?
<import type="androidx.lifecycle.LiveData"/>
<import type="java.util.List"/>
<variable
name="livedata"
type="LiveData<List>"/>
when compiling it throw error: incompatible types: Object cannot be converted to List but if i am using primitive type it work , how can i do this with List type?
Upvotes: 1
Views: 373
Reputation: 96
You must infer the type of list, for example, if list is of type List of Integers you must do:
<import type="androidx.lifecycle.LiveData"/>
<import type="java.util.List"/>
<import type="Integer"/>
<variable
name="livedata"
type="LiveData<List<Integer>>"/>
Upvotes: 3