Hi was just wondering if anyone here is able to help me. I am making an app and have just created a new activity and am trying to load that activity when I click on a ImageButton. I thought I had done it correctly but I am now getting a crash every time i go to run the app.
Does this error message make sense to anyone? Would really appreciate some help! Thank you
Does this error message make sense to anyone? Would really appreciate some help! Thank you
Code:
09-19 17:31:19.238 2625-2625/com.dan.fletcher.golearnthai E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dan.fletcher.golearnthai, PID: 2625
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dan.fletcher.golearnthai/com.dan.fletcher.golearnthai.MainActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatImageButton cannot be cast to android.widget.Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatImageButton cannot be cast to android.widget.Button
at com.dan.fletcher.golearnthai.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
at android.app.ActivityThread.access$1100(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
[code]
Attachments
-
Screen Shot 2016-09-19 at 17.44.54.png130.5 KB · Views: 218
-
Screen Shot 2016-09-19 at 17.44.49.png75.2 KB · Views: 200
-
Screen Shot 2016-09-19 at 17.44.41.png182.3 KB · Views: 224
-
Screen Shot 2016-09-19 at 17.44.29.png179 KB · Views: 233
-
Screen Shot 2016-09-19 at 17.44.15.png502.8 KB · Views: 228
-
Screen Shot 2016-09-19 at 17.43.56.png898.9 KB · Views: 271
Last edited: