GithubHelp home page GithubHelp logo

datalink747 / masked-edittext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinball83/masked-edittext

0.0 1.0 0.0 98 KB

Android library contain custom realisation of EditText component for masking and formatting input text

License: Apache License 2.0

Java 100.00%

masked-edittext's Introduction

Masked-Edittext

Download

Masked-Edittext android library EditText widget wrapper add masking and formatting input text functionality.

![Image phone number formatted input] (http://g.recordit.co/ROo3bzrX7k.gif)

![Image card number formatted input] (http://g.recordit.co/B8IuMTrsYi.gif)

Install

##Maven

<dependency>
  <groupId>com.github.pinball83</groupId>
  <artifactId>masked-edittext</artifactId>
  <version>1.0.1</version>
  <type>aar</type>
</dependency>

##Gradle

compile 'com.github.pinball83:masked-edittext:1.0.1'

#Usage ###Quick start You can choose using this widget thought declaring it in layout resource xml

<com.github.pinball83.maskededittext.MaskedEditText
                android:id="@+id/masked_edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="number"
                app:mask="8 (***) *** **-**"
                app:notMaskedSymbol="*"
                app:maskIcon="@drawable/abc_ic_clear_mtrl_alpha"
                app:maskIconColor="@color/colorPrimary"
                />

or programmatically create in source file

MaskedEditText maskedEditText = new MaskedEditText(this,
                "8 (***) *** **-**",
                "*",
                getResources().getDrawable(R.drawable.ic_account_circle),
                new MaskedEditText.MaskIconCallback() {
                    @Override
                    public void onIconPushed() {
                        System.out.println("Icon pushed");
                        //Invoke here contact list or just clear input
                    }
                });

###Attributes
MaskedEditText have following attributes

####XML ... app:mask = "8 () *** -" //mask app:notMaskedSymbol = "" //symbol for mapping allowed placeholders app:replacementChar = "#" //symbol which will be replaced notMasked symbol e.g. 8 (*) *** - will be 8 (###) ### ##-## by default it assign to whitespace app:deleteChar = "#" //symbol which will be replaced after deleting by default it assign to whitespace app:format = "[1][2][3] [4][5][6]-[7][8]-[10][9]" //set format of returned data input into MaskedEditText app:maskIcon = "@drawable/abc_ic_clear_mtrl_alpha" //icon for additional functionality clean input or invoke additional screens app:maskIconColor = "@color/colorPrimary" //icon tint color ...

####Java Simple instance

MaskedEditText editText = new MaskedEditText(context, "8 (***) *** **-**", "*"); //set mask to "8 (***) *** **-**" and not masked symbol to "*"

text setup and formatting

editText.setMaskedText("5551235567");                     //set text into widget it will be look like 8 (555) 123 55-67
editText.setFormat("[1][2][3] [4][5][6]-[7][8]-[10][9]"); //set format of returned data input into MaskedEditText e.g editText.getUnmaskedText() return 8 (555) 123 55-76

Widget instance with mask, icon button and callback

MaskedEditText maskedEditText = new MaskedEditText(this,
            "8 (***) *** **-**",
            "*",
            getResources().getDrawable(R.drawable.ic_account_circle),
            new MaskedEditText.MaskIconCallback() {
                @Override
                public void onIconPushed() {
                    System.out.println("Icon pushed");
                }
            });

Getting text

maskedEditText.getUnmaskedText() //return unmasked text
maskedEditText.getText()         //return mask and text

masked-edittext's People

Watchers

Soussi  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.