Hi all,
I want to limit the size of text in an edit box. I've seen the solutions proposed in this post: https://www.b4x.com/android/forum/posts/560798/
but such code worked only in debug mode, not in release.
I made a small change:
and this worked in debug AND in release mode.
Hope it will be useful for someone...
edited Jun 9, 2018 : it DOESN'T work if the textview is in password mode! Does anyone have an alternate solution for such case ?
I want to limit the size of text in an edit box. I've seen the solutions proposed in this post: https://www.b4x.com/android/forum/posts/560798/
but such code worked only in debug mode, not in release.
I made a small change:
B4X:
Sub CutText(Tf As TextField, MaxLength As Int)
Tf.ResignFocus
Tf.Text = Tf.Text.SubString2(0,MaxLength)
Tf.RequestFocus
End Sub
Private Sub txtOnt_TextChanged (Old As String, New As String)
If New.Length > 5 Then ' if string too long
CallSubDelayed3(Me, "CutText", txtOnt, 5) ' reduce to the allowed size
' CutText(txtOnt, 5) ' also works in immediate mode
End If
End Sub
and this worked in debug AND in release mode.
Hope it will be useful for someone...
edited Jun 9, 2018 : it DOESN'T work if the textview is in password mode! Does anyone have an alternate solution for such case ?
Last edited: