【问题标题】:App crashes when changing into light to dark mode切换到浅色模式时应用程序崩溃
【发布时间】:2021-06-22 02:15:24
【问题描述】:

在我的主要活动中,我附加了两个片段并使用了 tablayout。每当我将浅色改为深色或深色改为浅色时,我都会收到此错误enter image description here

    Process: com.umobi.scantags, PID: 24666
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.umobi.scantags/com.umobi.scantags.activities.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.umobi.scantags.fragments.DeactiveFragment: could not find Fragment constructor

错误显示在 onCreate()super.onCreate(savedInstanceState) 主活动中。

【问题讨论】:

  • 尝试在 Fragments 中添加一个空的构造函数!

标签: android android-studio kotlin android-fragments oncreate


【解决方案1】:

无法实例化片段 com.umobi.scantags.fragments.DeactiveFragment:找不到片段构造函数

您的 DeactiveFragment 需要一个零参数构造函数,或者您需要注册一个 FragmentFactory 来实例化没有零参数构造函数的片段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多