I'm trying to start an activity in my UI by passin...
# anko
b
I'm trying to start an activity in my UI by passing in the type. However, I'm getting this error and I'm not sure what it means.
Copy code
Cannot use 'ACT' as reified type parameter. Use a class instead.
code:
Copy code
class myClass<ACT: Activity>(): AnkoComponent<Fragment> ....
    ....
    floatingActionButton
    ....
    .setOnClickListener {
        startActivity<ACT>()
    }
d
blakelee:
ACT
is an erased type parameter, but
startActivity
requires a reified type parameter. explanation of type erasure in Java (same applies to Kotlin): https://stackoverflow.com/a/313590/3677267 reified type parameters in inline functions: https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters to solve your problem, you'll have to pass a
Class<ACT>
to your class and use it as an argument to
startActivity
b
Unfortunately it's saying the variable I've passed in is unresolved. I can use it everywhere else but for the startActivity
I don't think it's meant to be done