我是Android开发的新手。我在使用平板电脑的两个列表片段时遇到问题,即左侧(FragmentA)和右侧(FragmentB)片段的两侧都是列表视图。将FragmentA与FragmentB进行通信没有问题。但是当我点击FragmentB的项目时,它会打开其他片段(称为FragmentC),当FragmentC的视图被充气时,如果我点击FragmentA然后我的应用程序崩溃了它给了我异常classnotcastexception。我已经发布了我的代码,但没有任何人满意的答复。
附加代码的问题链接
Error while working with two Fragment in android
我的错误日志
05-22 08:55:15.292: E/AndroidRuntime(838): FATAL EXCEPTION: main
05-22 08:55:15.292: E/AndroidRuntime(838): java.lang.ClassCastException: com.example.illusion.FragmentC cannot be cast to com.example.illusion.FragmentB
05-22 08:55:15.292: E/AndroidRuntime(838): at com.example.illusion.MainActivity.respond(MainActivity.java:38)
05-22 08:55:15.292: E/AndroidRuntime(838): at com.example.illusion.FragmentA.onItemClick(FragmentA.java:34)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2788)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.widget.AbsListView$1.run(AbsListView.java:3463)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.os.Handler.handleCallback(Handler.java:730)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.os.Handler.dispatchMessage(Handler.java:92)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.os.Looper.loop(Looper.java:137)
05-22 08:55:15.292: E/AndroidRuntime(838): at android.app.ActivityThread.main(ActivityThread.java:5103)
05-22 08:55:15.292: E/AndroidRuntime(838): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 08:55:15.292: E/AndroidRuntime(838): at java.lang.reflect.Method.invoke(Method.java:525)
05-22 08:55:15.292: E/AndroidRuntime(838): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-22 08:55:15.292: E/AndroidRuntime(838): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-22 08:55:15.292: E/AndroidRuntime(838): at dalvik.system.NativeStart.main(Native Method)