awesum
awesum

Reputation: 35

Masking Input in EditText in Android

How to use inputfilter for CNIC i.e #####-#######-# ? Please help me.. I am new to Android and I dont know how to use it?

How to mask input? I went through various sites but couldn't find solution. I am so confused.

Upvotes: 1

Views: 13997

Answers (2)

Slava
Slava

Reputation: 1302

) You can also try the fork of Masked EditText. It's derived but with works with Gradle, has some bugfixes, an example project, and a little bit another behavior :-)

The behavior is also changed:

  1. You can set the flag and the hint will be always visible.
  2. Your pattern is invisible initially and grows automatically as soon, as you type. For instance, in the beginning, it is: "+7(", then you type '999' and it shows you "+7(999)" with another brace. In the original library, AFAIK it works like: "+7( ) - - ", then you type '999' and it transforms into "+7(999) - - " and so on.

Upvotes: 1

Yash Sampat
Yash Sampat

Reputation: 30601

Have you tried using Masked EditText ? This is what you want ... :)

If you want a numeric keyboard instead of alphabetical, then comment the following lineof code:

this.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

in the file MaskedEditText.java. Now setting android:inputType = "numeric" will work.

Upvotes: 7

Related Questions