How to automatically capitalize the first letter of a sentence in EditText?

bsnqt

Active Member
Licensed User
Longtime User
Dear All

I want my Edit Text automatically capitalize the first letter of the sentence when users make their texting.

I did make a search in the forum but got confused now. I see different INPUT_TYPE but did not get any to work right. Please advise.

B4X:
Sub Edit_Message_TextChanged(Old As String, New As String)
   Dim edt As EditText
   edt = Sender
   
   If New.EndsWith(". ") OR New.EndsWith("." & Chr(10)) Then
      edt.InputType =  Bit.OR(131072, 4096) '4096--> All CAPITAL LETTERS
   Else
      edt.InputType = Bit.OR(edt.INPUT_TYPE_TEXT, 131072) ' 131072 --> Multiline
   End If
   
End Sub

Thank you for your advice.

Best
 

stevel05

Expert
Licensed User
Longtime User
Have a look Here.

You'd need
B4X:
InpTyp.SetInputType(EditText8,Array As Int(InpTyp.TYPE_CLASS_TEXT,InpTyp.TYPE_TEXT_FLAG_CAP_WORDS))
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi stevel05,

Thank you very much, it works perfectly! However, I should change a little bit the value, it is like this:

B4X:
InpTyp.SetInputType(EditText8,Array As Int(InpTyp.TYPE_CLASS_TEXT,InpTyp.TYPE_TEXT_FLAG_CAP_SENTENCES))

Once again thank you!
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm glad you found what you wanted, I picked the wrong option in a hurry.
 
Upvote 0
Top