Simple Kotlin Project does not show any UI

瘦欲@ 提交于 2021-02-04 08:40:21

问题


I have a very simple Android Project in Kotlin. Just to dig in Kodein. I can not see the two TextViews in the main_layout?

I have used MVP pattern for the only MainActivity I have there..

The app starts without a crash and is show a blank white screen.

Any hints?

BaseActivity:

abstract class BaseActivity<V : BasePresenter.View> : AppCompatActivity(), BasePresenter.View  {

    protected abstract val layoutResourceId : Int
    protected abstract val presenter : BasePresenter<V>

    val kodeinMu = LazyKodein(appKodein)

    protected abstract fun initUI()
    protected abstract fun initPresenter()

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
        setContentView(layoutResourceId)

        initUI()
        initPresenter()
    }

    override fun onPause() {
        super.onPause()
        presenter.pause()
    }

    override fun onStop() {
        super.onStop()
        presenter.stop()
    }

    override fun onDestroy() {
        super.onDestroy()
        presenter.destroy()
    }

    protected fun toast(s: String) {
        System.out.println("TAG $s")
    }
}

I have read that it is because of API 28 you only can see on API_28 devices or emulators. Either emulator or on real device were also blanked out.


回答1:


You override the wrong onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) in you activity: use this : onCreate(savedInstanceState: Bundle?)



来源:https://stackoverflow.com/questions/54437922/simple-kotlin-project-does-not-show-any-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!