2014-01-23 63 views
0

我試圖做一個聲卡,但我得到這個錯誤。聲卡與ImageButtons

我可能正在讀取日誌錯誤,但它看起來有些圖像按鈕有問題。

任何想法??

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 

回答

4

它告訴你一清二楚,android.widget.ImageButton cannot be cast to android.widget.Button在`Content.java」在行106

你可能有有一份聲明中讀取類似

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

時,它應該是

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

很高興我能幫到你。 Logcat是你的朋友,朋友! – 323go