0

我正在尝试制作我的第一个应用程序,并且制作了 2 个页面(LogoActivity(主页面)和 screen_2)。除了 LogCat,我没有任何问题。我不知道那是什么。如果你能告诉我一些事情,我很高兴学习:)。这是我从 Eclipse 获得的日志文件。

05-15 21:04:04.981: D/AndroidRuntime(382): Shutting down VM
05-15 21:04:04.981: W/dalvikvm(382): threadid=1: thread exiting with uncaught exception (group=0x40015560)
05-15 21:04:05.001: E/AndroidRuntime(382): FATAL EXCEPTION: main    
05-15 21:04:05.001: E/AndroidRuntime(382): java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.eyestudios.logo/eu.eyestudios.logo.LogoActivity}: java.lang.ClassCastException: android.widget.ImageButton
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)    
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.os.Looper.loop(Looper.java:123)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread.main(ActivityThread.java:3683)
05-15 21:04:05.001: E/AndroidRuntime(382):  at java.lang.reflect.Method.invokeNative(Native Method)
05-15 21:04:05.001: E/AndroidRuntime(382):  at java.lang.reflect.Method.invoke(Method.java:507)
05-15 21:04:05.001: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-15 21:04:05.001: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-15 21:04:05.001: E/AndroidRuntime(382):  at dalvik.system.NativeStart.main(Native Method)
05-15 21:04:05.001: E/AndroidRuntime(382): Caused by: java.lang.ClassCastException: android.widget.ImageButton
05-15 21:04:05.001: E/AndroidRuntime(382):  at eu.eyestudios.logo.LogoActivity.onCreate(LogoActivity.java:14)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-15 21:04:05.001: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-15 21:04:05.001: E/AndroidRuntime(382):  ... 11 more

非常感谢!:)

4

2 回答 2

1

这些行

05-15 21:04:05.001: E/AndroidRuntime(382): 由: java.lang.ClassCastException: android.widget.ImageButton

05-15 21:04:05.001: E/AndroidRuntime(382): at eu.eyestudios.logo.LogoActivity.onCreate(LogoActivity.java:14)

告诉您您正在尝试进行无效类型的强制转换。检查代码LogoActivity.java:14以找出你的演员有什么问题。

于 2012-05-15T21:20:10.363 回答
0
The problem is in the imagebutton:

05-15 21:04:05.001: E/AndroidRuntime(382): Caused by: java.lang.ClassCastException: android.widget.ImageButton

I think you have not find image button by findviewbyid or you are taking wrong id for image button.like (ImageButton)findViewById(R.Id.***imagebutton**)..Check this id matches with image button id in xml.
于 2012-05-16T05:53:00.160 回答