Android 带图像按钮的声卡

Android 带图像按钮的声卡,android,Android,我正试图制作一个音板,但我遇到了这个错误 我可能读错了日志,但图像按钮似乎有问题 有什么想法吗 01-23 15:59:03.667: E/AndroidRuntime(19712): FATAL EXCEPTION: main 01-23 15:59:03.667: E/AndroidRuntime(19712): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bluf

我正试图制作一个音板,但我遇到了这个错误

我可能读错了日志,但图像按钮似乎有问题

有什么想法吗

  01-23 15:59:03.667: E/AndroidRuntime(19712): FATAL EXCEPTION: main
    01-23 15:59:03.667: E/AndroidRuntime(19712): java.lang.RuntimeException: 
Unable to start activity ComponentInfo{com.example.bluffball/com.example.bluffball.Content}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread.access$600(ActivityThread.java:138)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.os.Handler.dispatchMessage(Handler.java:99)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.os.Looper.loop(Looper.java:213)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread.main(ActivityThread.java:4787)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at java.lang.reflect.Method.invokeNative(Native Method)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at java.lang.reflect.Method.invoke(Method.java:511)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at dalvik.system.NativeStart.main(Native Method)
    01-23 15:59:03.667: E/AndroidRuntime(19712): Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at com.example.bluffball.Content.onCreate(Content.java:106)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.Activity.performCreate(Activity.java:5008)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
    01-23 15:59:03.667: E/AndroidRuntime(19712):    ... 11 more
    01-23 15:59:05.789: I/Process(19712): Sending signal. PID: 19712 SIG: 9

它非常清楚地告诉您,
android.widget.ImageButton不能强制转换为第106行“Content.java”中的android.widget.Button

你可能有一个声明,上面写着

Button someButton = (Button) findViewById( R.id. ... )
应该是什么时候

ImageButton someButton = (ImageButton) findViewById( R.id. ... )

它非常清楚地告诉您,
android.widget.ImageButton不能强制转换为第106行“Content.java”中的android.widget.Button

你可能有一个声明,上面写着

Button someButton = (Button) findViewById( R.id. ... )
应该是什么时候

ImageButton someButton = (ImageButton) findViewById( R.id. ... )

很高兴我能帮忙。Logcat是你的朋友,朋友!很高兴我能帮忙。Logcat是你的朋友,朋友!