Estoy intentando hacer un navegador con botones simples, los cuales tendrán imágenes .png como íconos. Mi aplicación no funciona cuando uso:
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button_icon"
android:contentDescription="@string/button_icon_desc"
... />
Pero funciona perfectamente cuando se ocupa:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_text"
... />
Aquí el URL de error generador por URL:
time: 1615083200067 msg: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button stacktrace: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidbrowser/com.androidbrowser.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3431) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7661) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:594) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: java.lang.ClassCastException: android.widget.ImageButton cannot be cast to android.widget.Button at com.androidbrowser.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:8000) at android.app.Activity.performCreate(Activity.java:7984) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3404) ... 11 more