Android Question EditText max characters?

techknight

Well-Known Member
Licensed User
Longtime User
Is there a way to either set, or programmatically check the number of characters being entered during typing?

Reason I ask, is I want to have an Edit Text with a Character limit of 20. So after 20 characters have been entered, stop the typing, or pop up a message, etc..

any ideas?
 

sorex

Expert
Licensed User
Longtime User
there is a textChanged event that you can use to count the chars and if it's bigger than you limit put back the old value.

someone put this in a codemodule once but it's easy to make it yourself.
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi,

try this :

B4X:
    Dim IME As IME
    Dim edtTest As EditText
   
    edtTest.Initialize("")
    IME.Initialize("")
    IME.SetLengthFilter(edtTest, 20)
 
Upvote 0
Top