Is there a way to limit the number of characters a user can enter into EditText? In VB6 I would use the MaxLength property.
Something like:
B4X:Sub EditText1_TextChanged (Old As String, New As String) If New > 100000 Then EditText1.Text = Old End Sub
Sub Globals
Dim etxQuantity As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("myLayout")
End Sub
Sub etxQuantity_TextChanged (Old As String, New As String)
If New.Length > 1000 Then etxQuantity.Text = Old
End Sub
Sub EditText1_TextChanged (Old As String, New As String)
If New.Length > 20 Then EditText1.Text = Old
End Sub
java.lang.IndexOutOfBoundsException: setSpan (11 ... 23) ends beyond length 20
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:945)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:527)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:520)
at android.widget.TextView.setSpan_internal(TextView.java:11473)
at android.widget.TextView$SuggestionsPopupWindow.onItemClick(TextView.java:9988)
at android.widget.AdapterView.performItemClick(AdapterView.java:292)
at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
at android.widget.AbsListView$1.run(AbsListView.java:3168)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592)
at dalvik.system.NativeStart.main(Native Method)