gpt4 book ai didi

android - 移动图像按钮后,应用程序崩溃!安卓

转载 作者:行者123 更新时间:2023-12-03 16:54:44 25 4
gpt4 key购买 nike

因此,我最近开发的应用程序进展顺利,我只是在应用程序后台更新了图像。好了,在我调整图像按钮使其与我制作的图像对齐之前,该应用程序就可以正常工作。在我移动它后,该应用将不再起作用,并且我尝试了所有尝试均未成功。这是 Activity 的xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/title_screen"
tools:context=".TitleScreen" >

<TextView
android:id="@+id/txtCoins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:layout_marginTop="11dp"
android:text="000"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#f3c50d"
android:textSize="12sp" />

<ImageButton
android:id="@+id/imageBtnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtCoins"
android:layout_centerHorizontal="true"
android:layout_marginTop="51dp"
android:background="@null"
android:src="@drawable/btn_play" />

</RelativeLayout>

编辑:这是我的logcat
03-20 17:08:29.847: W/dalvikvm(28692): threadid=1: thread exiting with uncaught exception (group=0x416282a0)
03-20 17:08:29.852: E/AndroidRuntime(28692): FATAL EXCEPTION: main
03-20 17:08:29.852: E/AndroidRuntime(28692): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ChonBonStudios.Tidbits/com.ChonBonStudios.Tidbits.TitleScreen}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageButton
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.os.Looper.loop(Looper.java:137)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-20 17:08:29.852: E/AndroidRuntime(28692): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 17:08:29.852: E/AndroidRuntime(28692): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
03-20 17:08:29.852: E/AndroidRuntime(28692): at dalvik.system.NativeStart.main(Native Method)
03-20 17:08:29.852: E/AndroidRuntime(28692): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageButton
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.ChonBonStudios.Tidbits.TitleScreen.onCreate(TitleScreen.java:20)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.Activity.performCreate(Activity.java:5191)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-20 17:08:29.852: E/AndroidRuntime(28692): ... 11 more

最佳答案

android.widget.TextView cannot be cast to android.widget.ImageButton



您在 Activity 中转换为错误的类,将 TextView更改为 ImageButton类中的 com.ChonBonStudios.Tidbits.TitleScreen

关于android - 移动图像按钮后,应用程序崩溃!安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15534656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com