Hi All,
I have a Sub that "in Part" back spaces text in an Edittext. In some circumstances an empty string is returned from the Edittext when it still contains text.
The BS only applies to numeric values although the text can contain non-numeric Chrs. When there is only one chr or only one chr before a non-numeric chr an empty string is returned. [Crash]
I have attached all the relevent code including the Logs, any help appreciated.
Regards Roger
I have a Sub that "in Part" back spaces text in an Edittext. In some circumstances an empty string is returned from the Edittext when it still contains text.
The BS only applies to numeric values although the text can contain non-numeric Chrs. When there is only one chr or only one chr before a non-numeric chr an empty string is returned. [Crash]
I have attached all the relevent code including the Logs, any help appreciated.
Regards Roger
B4X:
Sub BtnDEL
Log("Idisplay.Text = " & Idisplay.Text)
Log("Idisplay.Text.Length = " & Idisplay.Text.Length)
Idisplay.Text = Idisplay.Text.SubString2(0,Idisplay.Text.Length-1) 'Line 695
Log("NewIdisplay.Text = " & Idisplay.Text)
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
Idisplay.SingleLine = False
Idisplay.Wrap = False
End Sub
B4X:
Sub IDisplay_TextChanged (Old As String, New As String)
Idisplay.SelectionStart = Idisplay.text.Length
End Sub
B4X:
** Activity (main) Create, isFirst = true **
No wakelock.
** Activity (main) Resume **
** Activity (main) Resume **
Idisplay.Text = 123+4567
Idisplay.Text.Length = 8
NewIdisplay.Text = 123+456
Idisplay.Text = 123+456
Idisplay.Text.Length = 7
NewIdisplay.Text = 123+45
Idisplay.Text = 123+45
Idisplay.Text.Length = 6
NewIdisplay.Text = 123+4
Idisplay.Text =
Idisplay.Text.Length = 0
Error occurred on line: 695 (Main)
java.lang.StringIndexOutOfBoundsException: length=0; regionStart=0; regionLength=-1
at java.lang.String.startEndAndLength(String.java:588)
at java.lang.String.substring(String.java:1475)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
at android.view.View.performClick(View.java:4623)
at android.view.View$PerformClick.run(View.java:19230)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **