java.lang.IllegalStateException:Fragment没有视图

时间:2015-10-01 15:57:48

标签: java android android-fragments

我有一个显示DialogFragment的活动,在该对话框片段中我有一个包含一个按钮的linearlayout,以及一个我要显示信息的fragmentLAyout。

我必须显示一个元素列表,如果有任何元素被按下,我必须显示它们的详细信息。我认为最好的方法是使用片段,当试图调用

FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        transaction.add(R.id.framePlaceHolder, listAccountFragment).commit();

创建listAccountFragment后,我收到此错误

10-01 10:53:34.004  12836-12836/com.bbva.compassBuzz.qa.debug E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.bbva.compassBuzz.qa.debug, PID: 12836
    java.lang.IllegalStateException: Fragment does not have a view
            at android.support.v4.app.Fragment$1.findViewById(Fragment.java:1746)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:943)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.Fragment.performResume(Fragment.java:1836)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:993)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1136)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1499)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:456)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5253)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1384)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1179)

0 个答案:

没有答案