https://kotlinlang.org logo
#android
Title
# android
k

Kevin Janvier Chinabalire

02/26/2019, 6:55 PM
hey there , how do you access any type inside your adapter eg:
val list:Any
then how do i access the value of
Any
e

edwardwongtl

02/27/2019, 3:34 AM
Do you know that type it will be?
k

Kevin Janvier Chinabalire

02/27/2019, 6:47 AM
@edwardwongtl it can be an object or a list
e

edwardwongtl

02/27/2019, 7:09 AM
If you know what type it will be at runtime, you can just check the type and do casting to access those values.
k

Kevin Janvier Chinabalire

02/27/2019, 7:23 AM
@edwardwongtl look the type changes ....
object.png
as an object it this
Then this a list
in the same response ... i get flight as type Any
e

edwardwongtl

02/27/2019, 7:27 AM
That’s why I said you need a check before doing the casting
k

Kevin Janvier Chinabalire

02/27/2019, 7:30 AM
not sure getting what u r meaning .. if(list is object ) else is an array ... do u mean so ?
e

edwardwongtl

02/27/2019, 7:30 AM
Yes
k

Kevin Janvier Chinabalire

02/27/2019, 7:31 AM
i tried that ...no success
e

edwardwongtl

02/27/2019, 7:32 AM
Any code to show?
k

Kevin Janvier Chinabalire

02/27/2019, 7:36 AM
give me a minute will show u a snip ..
i have send you what am doing
but not workng
2 Views