Arf Well-Known Member Licensed User Longtime User Jun 2, 2015 #1 I've got a EditText box set up for numbers only, into which a height number is typed. When I try read the content, I imagine it will be casted automatically. However, I get a crash on the second line below, 'Invalid Double'. Code: Dim height as int height = heightText.Text What is the correct way do this, use a stringToInt function?
I've got a EditText box set up for numbers only, into which a height number is typed. When I try read the content, I imagine it will be casted automatically. However, I get a crash on the second line below, 'Invalid Double'. Code: Dim height as int height = heightText.Text What is the correct way do this, use a stringToInt function?
Arf Well-Known Member Licensed User Longtime User Jun 2, 2015 #2 Oops, ignore this question. heightText had not had a value typed in, and the initial string from the designer contained a non-numeric string. Upvote 0
Oops, ignore this question. heightText had not had a value typed in, and the initial string from the designer contained a non-numeric string.
Arf Well-Known Member Licensed User Longtime User Jun 2, 2015 #3 Retract, retract! The inital string did no seem to be the problem after all. Still have problems. Log is below: java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:248) at java.lang.Double.parseDouble(Double.java:295) at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:50) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA.raiseEvent(BA.java:171) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77) at android.view.View.performClick(View.java:4452) at android.widget.Button.performClick(Button.java:148) at android.view.View$PerformClick.run(View.java:18428) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Upvote 0
Retract, retract! The inital string did no seem to be the problem after all. Still have problems. Log is below: java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:248) at java.lang.Double.parseDouble(Double.java:295) at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:50) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA.raiseEvent(BA.java:171) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77) at android.view.View.performClick(View.java:4452) at android.widget.Button.performClick(Button.java:148) at android.view.View$PerformClick.run(View.java:18428) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5365) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method)
Arf Well-Known Member Licensed User Longtime User Jun 2, 2015 #4 and a correction, I'm actually trying to convert to float, not int: Code: Dim height as Float height = heightText.Text Upvote 0
and a correction, I'm actually trying to convert to float, not int: Code: Dim height as Float height = heightText.Text
DonManfred Expert Licensed User Longtime User Jun 2, 2015 #5 An Empty String cannot be parsed to a Double, Int, Long, Float Upvote 0
klaus Expert Licensed User Longtime User Jun 2, 2015 #6 You should put a correct default value in your EditText view. Upvote 0