简单的Kotlin项目不显示任何UI [英] Simple Kotlin Project does not show any UI
问题描述
我有一个科特林非常简单的Android项目.只是为了挖科丁.我在main_layout中看不到两个TextViews?
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.
有任何提示吗?
BaseActivity:
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")
}
}
我读到这是因为您只有在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屋!