自定义Dialog加载Fragment无法找到id的问题

  • Post author:
  • Post category:其他


 java.lang.IllegalArgumentException: No view found for id 0x7f080090 (com.colin.kingcar:id/home_container) for fragment SettingFragment{44154c5 #2 id=0x7f080090}
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1292)
        at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2430)
        at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2209)
        at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2165)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2066)
        at android.app.FragmentManagerImpl$1.run(FragmentManager.java:738)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7050)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

解决方法:

注意,如果只是控件继承Dialog是无法加载Fragment的,需要继承自DialogFragment,实现onCreateView即可



版权声明:本文为gsrkuang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。