问题描述
- android虚拟机里程序一直停止运行
- ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=edu.nuist.zhangtong.baiduMap/.LoginActivity }
logcat:
01-05 00:06:04.698: D/dalvikvm(1225): Not late-enabling CheckJNI (already on)
01-05 00:06:09.188: D/AndroidRuntime(1225): Shutting down VM
01-05 00:06:09.198: W/dalvikvm(1225): threadid=1: thread exiting with uncaught exception (group=0xb2ad2ba8)
01-05 00:06:09.268: E/AndroidRuntime(1225): FATAL EXCEPTION: main
01-05 00:06:09.268: E/AndroidRuntime(1225): Process: edu.nuist.zhangtong.baiduMap PID: 1225
01-05 00:06:09.268: E/AndroidRuntime(1225): java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.nuist.zhangtong.baiduMap/edu.nuist.zhangtong.baiduMap.LoginActivity}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread.access$800(ActivityThread.java:135)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.os.Handler.dispatchMessage(Handler.java:102)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.os.Looper.loop(Looper.java:136)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread.main(ActivityThread.java:5017)
01-05 00:06:09.268: E/AndroidRuntime(1225): at java.lang.reflect.Method.invokeNative(Native Method)
01-05 00:06:09.268: E/AndroidRuntime(1225): at java.lang.reflect.Method.invoke(Method.java:515)
01-05 00:06:09.268: E/AndroidRuntime(1225): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
01-05 00:06:09.268: E/AndroidRuntime(1225): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
01-05 00:06:09.268: E/AndroidRuntime(1225): at dalvik.system.NativeStart.main(Native Method)
01-05 00:06:09.268: E/AndroidRuntime(1225): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
01-05 00:06:09.268: E/AndroidRuntime(1225): at edu.nuist.zhangtong.baiduMap.LoginActivity.onCreate(LoginActivity.java:26)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.Activity.performCreate(Activity.java:5231)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-05 00:06:09.268: E/AndroidRuntime(1225): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
01-05 00:06:09.268: E/AndroidRuntime(1225): ... 11 more
01-05 00:07:51.018: I/Process(1225): Sending signal. PID: 1225 SIG: 9
解决方案
log中有提示
01-05 00:06:09.268: E/AndroidRuntime(1225): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
01-05 00:06:09.268: E/AndroidRuntime(1225): at edu.nuist.zhangtong.baiduMap.LoginActivity.onCreate(LoginActivity.java:26)
第二句提示在LoginActivity中的onCreate的26行出错,第一句提示了出错信息:
类转换异常:TextView不能转成EditText。
你看一下自己的代码,是不是把本来是TextView的控件给写成了EditText。
如果不是上述情况的话,可能是你之前写错过,改过来了,但是eclipse还没有反应过来,可以clean一下,再build。
还不行的话,重启eclipse
解决方案二:
类型转发有问题,控件类型错了!。?