I'm loving the B4XFloatTextField and can't figure out how to limit what characters and text length the user can input.
My app will provide a string of the allowed characters and field length as this varies all the time.
If you wish to use the constants, you will need to cast the B4XView to the appropriate view type:
B4X:
Dim poTxt As EditText
poTxt = B4XEdTxtCode.TextField ' view is B4XFloatTextField and the .TextField property is B4XView not EditText
ime.SetCustomFilter(poTxt, poTxt.INPUT_TYPE_TEXT, chars)
Use the Tag property of the B4XFloatEdit With the Tag property in 10 characters for example the code would be:
B4X:
Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
If New.Length > B4XFloatTextField1.Tag Then
B4XFloatTextField1.Text = New.Substring2(0, B4XFloatTextField1.Tag)
End If
End Sub
I think you are missing some code. It should be like this:. Please confirm or refute:
B4X:
Sub B4XFloatTextField1_TextChanged (Old As String, New As String)
If New.Length > B4XFloatTextField1.Tag Then 'the tag has the max number of characters
B4XFloatTextField1.Text = New.Substring2(0, B4XFloatTextField1.Tag)
Dim et As EditText = B4XFloatTextField1.TextField
et.SelectionStart = et.text.Length
End If
End Sub