09-19 09:40:15.151 1440-1440/com.example.lenovo.application17fragment E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.lenovo.application17fragment, PID: 1440 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lenovo.application17fragment/com.example.lenovo.application17fragment.MainActivity}: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.RadioGroup at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.RadioGroup at com.example.lenovo.application17fragment.MainActivity.onCreate(MainActivity.java:15) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)
2 回答
四无小青年
TA贡献88条经验 获得超43个赞
android.widget.RelativeLayout cannot be cast to android.widget.RadioGroup
这句报错说明你是类型转换错误,布局中的控件和你代码中定义的控件类型不一致,检查一下MainActivity中第15代码。
- 2 回答
- 0 关注
- 1371 浏览
添加回答
举报
0/150
提交
取消