Skip to content

TextWatcher to handle input with empty spaces '_' and placeholders.

License

Notifications You must be signed in to change notification settings

GaidamakUA/SchemaTextWatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SchemaTextWatcher

TextWatcher to handle input with empty spaces '_' and placeholders. This functionality is great to have for credit cards and passwords input.

Usage example

To use the library you should copy and paste class SchemaTextWatcher and use it like this:

First example

editText = (EditText) view.findViewById(R.id.card_number);
editText.addTextChangedListener(new SchemaTextWatcher(editText, "____ ____ ____ ____"));

Second example

Alternatively you can use it like this:

editText = (EditText) view.findViewById(R.id.card_number);
editText.addTextChangedListener(new SchemaTextWatcher(editText));

And in layou you should set text as a future scheme for layout"

    <EditText
        android:id="@+id/card_number"
        style="@style/TextAppearance.DefaultText.EditText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:text="____ ____ ____ ____"
        android:maxLength="20"/>

Limitations:

For now only '_' for digits and ' ' for placeholders supported. And for now it can only work with digits. But I did my best to nicely structure code and make it extendable. So you can add your functianality by yourself.

About

TextWatcher to handle input with empty spaces '_' and placeholders.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages