这是我的观看活动LoginActivity
。 LoginActivityUI
是我的anko AnkoComponent
,用于展示视图。
@EActivity//not using R.layout.activity_login
open class LoginActivity : BaseActivity() {
//Anko view injection with dagger2
@Inject lateinit var ui: LoginActivityUI
//Forced to do this and its not neat
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ui.setContentView(this)
}
@AfterViews
fun afterView() {
//Never called
ui.setContentView(this)
}
@AfterInject
fun afterInject() {
//Called but ui not initialized
ui.setContentView(this)
}
}
答案 0 :(得分:0)
您必须根据活动生命周期覆盖onCreate
。