【发布时间】:2019-01-05 09:21:34
【问题描述】:
我正在使用导航架构组件库,我的应用的起点是这个片段:
class MainFragment : BaseFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main, container, false)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
继承自BaseFragment的抽象类:
abstract class BaseFragment : Fragment() {
}
当我运行我的应用程序时,我得到:
Unable to instantiate fragment io.example.MainFragment: calling Fragment constructor caused an exception
但如果MainFragment 扩展Fragment 而不是BaseFragment,则不会发生这种情况。是什么原因?这是否与导航架构组件的工作方式有关?
【问题讨论】:
-
在这里遇到类似的问题。找到解决方案了吗?
标签: android android-fragments android-architecture-components