I have created an app and it was running successfully till yesterday, by today when I tried running it on my device it shows the following error in logcat and my app gets crashed.
03-31 12:37:47.059: ERROR/(1916): java.lang.ClassCastException: android.widget.ImageView
03-31 12:37:47.239: ERROR/AndroidRuntime(1916): Uncaught handler: thread main exiting due to uncaught exception
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fis.flash/com.fis.flash.FirstImage}: java.lang.ClassCastException: android.widget.AbsoluteLayout
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.os.Lo开发者_如何学JAVAoper.loop(Looper.java:123)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread.main(ActivityThread.java:4363)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at java.lang.reflect.Method.invoke(Method.java:521)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at dalvik.system.NativeStart.main(Native Method)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): Caused by: java.lang.ClassCastException: android.widget.AbsoluteLayout
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at com.fis.flash.FirstImage.onCreate(FirstImage.java:106)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
03-31 12:37:47.246: ERROR/AndroidRuntime(1916): ... 11 more
It shows an error in a ImageView
of my main class activity, but all the details are been correct in my coding side.
What's this error, how to over come this?
hi i have found my error, i have assigned linear layout in one of my xml file but i have mentioned it to be absolute layout in my class file.
ClassCastException in FirstImage class on line 106 ? It seems you try to cast something as an AbsoluteLayout in onCreate() method where it is not.
source :
Caused by: java.lang.ClassCastException: android.widget.AbsoluteLayout 03-31 12:37:47.246: ERROR/AndroidRuntime(1916): at com.fis.flash.FirstImage.onCreate(FirstImage.java:106)
I was getting this error Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView:
I changed
stringsAdapter = new ArrayAdapter<String>(this,R.layout.main,myStrings);
To
stringsAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,myStrings);**
and problem is solved for me.
精彩评论