Can I use @Bean
from AndroidAnnotation
within Kotlin
?
@EActivity(R.layout.activity_test)
open class TestActivity : AppCompatActivity() {
@Bean
var test:TestBean //<-- IDE shows "property must be initialized or abstract"
This is my Bean
declaration
@EBean
class TestBean {
fun printShit(){
Log.e("ASDF","ASDF")
}
}
Is this somehow possible? Or do I have to use kotlins object
for this?
You can mark it lateinit
to avoid having to initialize it.
@Bean
lateinit var test: TestBean
By doing so, you're telling the compiler that you're sure it will be initialized before the first time you use it. If it doesn't get initialized and you try to use it, this will throw an exception.