简单的 Kotlin 项目不显示任何 UI [英] Simple Kotlin Project does not show any UI
问题描述
我有一个 非常简单的 Kotlin 安卓项目.只是为了挖掘 Kodein.我在 main_layout 中看不到两个 TextView?
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?
我在那里唯一的 MainActivity 使用了 MVP 模式..
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.
有什么提示吗?
基础活动:
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")
}
}
我读到这是因为 API 28 您只能在 API_28 设备或模拟器上看到.模拟器或真机也被屏蔽了.
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.
推荐答案
您在您的活动中重写了错误的 onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?)
:使用这个:onCreate(savedInstanceState: Bundle?)
You override the wrong onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?)
in you activity:
use this : onCreate(savedInstanceState: Bundle?)
这篇关于简单的 Kotlin 项目不显示任何 UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!