Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

android - Simple Kotlin Project does not show any UI

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...