Android Question Set by default all caps on edit text

ocalle

Active Member
Licensed User
Longtime User
Hello, Did someone know how set an Edit text input all in caps by default? , i seeked designer layout properties but dunno.-

EDT_TXT:AAAAMMMAAA

Thanks you as usually
 

ocalle

Active Member
Licensed User
Longtime User
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Why not to use ToUpperCase:
B4X:
Sub Globals

    Dim EditText1           As EditText
    Dim EditText2           As EditText
    Dim booleanIgnoreChange As Boolean

End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    EditText1.Initialize ("EditText1")
    Activity.AddView (EditText1, 10%x, 10%y, 80%x, 150dip)
    EditText2.Initialize ("EditText2")
    Activity.AddView (EditText2, 10%x, 10%y + 200dip, 80%x, 50dip)
   
End Sub

Sub Activity_Resume
   
    EditText1.Text = "This is a very important text"
    EditText2.Text = "Not a very important text"
   
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
   
    If booleanIgnoreChange = False Then
        booleanIgnoreChange = True
        Dim i As Int = EditText1.SelectionStart
        Dim j As Int = EditText1.SelectionLength
        EditText1.Text = (EditText1.Text).ToUpperCase               
        EditText1.SetSelection (i, j)
    Else
        booleanIgnoreChange = False
    End If
   
End Sub

Note, the letters will be capital even when you copy from second edittext.
 
Upvote 0

ocalle

Active Member
Licensed User
Longtime User
Why not to use ToUpperCase:
B4X:
Sub Globals

    Dim EditText1           As EditText
    Dim EditText2           As EditText
    Dim booleanIgnoreChange As Boolean

End Sub

Sub Activity_Create(FirstTime As Boolean)
 
    EditText1.Initialize ("EditText1")
    Activity.AddView (EditText1, 10%x, 10%y, 80%x, 150dip)
    EditText2.Initialize ("EditText2")
    Activity.AddView (EditText2, 10%x, 10%y + 200dip, 80%x, 50dip)
 
End Sub

Sub Activity_Resume
 
    EditText1.Text = "This is a very important text"
    EditText2.Text = "Not a very important text"
 
End Sub

Sub EditText1_TextChanged (Old As String, New As String)
 
    If booleanIgnoreChange = False Then
        booleanIgnoreChange = True
        Dim i As Int = EditText1.SelectionStart
        Dim j As Int = EditText1.SelectionLength
        EditText1.Text = (EditText1.Text).ToUpperCase            
        EditText1.SetSelection (i, j)
    Else
        booleanIgnoreChange = False
    End If
 
End Sub

Note, the letters will be capital even when you copy from second edittext.




Thanks i just remember in old programming times when i used Dbase III u need declare a field with (!), with a single definition of the string field and it take caps by default, the time has changed :D
 
Upvote 0
Top