是正确的铸造吗?按下按钮后,应用程序正在关闭。如果我在第二行 ( ) 上切换评论,height = Integer
那么它工作正常。
public void onClick(View v)
{
EditText tHeight = (EditText)findViewById(R.id.tbHeight);
height = Integer.parseInt(tHeight.getText().toString());
}
如果您指的是此日志,则为完整日志:
02-09 14:41:58.941: I/dalvikvm(15417): Turning on JNI app bug workarounds for target SDK version 5...
02-09 14:42:03.918: D/AndroidRuntime(15417): Shutting down VM
02-09 14:42:03.918: W/dalvikvm(15417): threadid=1: thread exiting with uncaught exception (group=0x40bf11f8)
02-09 14:42:03.918: E/AndroidRuntime(15417): FATAL EXCEPTION: main
02-09 14:42:03.918: E/AndroidRuntime(15417): java.lang.NumberFormatException: Invalid int: ""
02-09 14:42:03.918: E/AndroidRuntime(15417): at java.lang.Integer.invalidInt(Integer.java:138)
02-09 14:42:03.918: E/AndroidRuntime(15417): at java.lang.Integer.parseInt(Integer.java:359)
02-09 14:42:03.918: E/AndroidRuntime(15417): at java.lang.Integer.parseInt(Integer.java:332)
02-09 14:42:03.918: E/AndroidRuntime(15417): at com.example.as.MainActivity$1.onClick(MainActivity.java:64)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.view.View.performClick(View.java:3558)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.view.View$PerformClick.run(View.java:14157)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.os.Handler.handleCallback(Handler.java:605)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.os.Handler.dispatchMessage(Handler.java:92)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.os.Looper.loop(Looper.java:137)
02-09 14:42:03.918: E/AndroidRuntime(15417): at android.app.ActivityThread.main(ActivityThread.java:4514)
02-09 14:42:03.918: E/AndroidRuntime(15417): at java.lang.reflect.Method.invokeNative(Native Method)
02-09 14:42:03.918: E/AndroidRuntime(15417): at java.lang.reflect.Method.invoke(Method.java:511)
02-09 14:42:03.918: E/AndroidRuntime(15417): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
02-09 14:42:03.918: E/AndroidRuntime(15417): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
02-09 14:42:03.918: E/AndroidRuntime(15417): at dalvik.system.NativeStart.main(Native Method)