This can result in your app crashing if using a dictionary/Spellchecking
Sub EditText1_TextChanged (Old As String, New As String)
If New.Length > 20 Then EditText1.Text = Old
End Sub
If you happen to type into the EditText1 somewhere say 15 characters, and then start typing another word, and your dictionary/spellchecking pops up because of misspelling, and you choose a word that will put you over your max character limit then your app will crash. Maybe someone else can confirm this as I'm running my app in an emulator.
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)
Best to use
EditText1.InputType = Bit.OR(EditText1.InputType, 524288)
to turn off spellchecking