B4J Question TextField filter for float number

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Is it really so that no any elegant solution for B4J textfield filters ? And we have to code each text filter individually.
For ex. to input a float number.
Any solution ?
 

peacemaker

Expert
Licensed User
Longtime User
specific range
No. OK, i have used Erel's old example for integers:

B4X:
Private Sub txtShift_TextChanged (Old As String, New As String)
    Dim sb As StringBuilder
    sb.Initialize
    For i = 0 To New.Length - 1
        If "-.0123456789".IndexOf(New.CharAt(i)) > -1 Then
            sb.Append(New.CharAt(i))
        End If
    Next
    txtShift.Text = sb.ToString
    txtShift.SetSelection(txtShift.Text.Length, txtShift.Text.Length)
End Sub
And i have to check "-", "-.", ".-", ".", "-.-" stupid inputs at saving.

But strange that no an universal solution, or the filtering textview (or my search was bad).
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
check this :
 
Upvote 0
Top