Coder Social home page Coder Social logo

maskededittext's Introduction

MaskedEditText


en_US

MakedEditText is a simple Android EditText with customizable input mask support.

JAR

If you want only the jar file it is available here.

Usage

Add xmlns:mask="http://schemas.android.com/apk/res/com.your.app.package" to your layout xml root. You're now ready to use MaskedEditText! Just add to your layout xml:

<br.com.sapereaude.maskedEditText.MaskedEditText 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    mask:mask="###.###.###-##"
/>

Where mask is the input mask you want and '#' is an editable position (will be replaced by a whitespace on screen).

You can optionally set the representation character (in case you don't want to use '#'):

<br.com.sapereaude.maskedEditText.MaskedEditText 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    mask:mask="ccc.ccc.ccc-cc"
    mask:char_representation="c"
/>

You can also change the mask and the representation character programatically:

MaskedEditText editText = (MaskedEditText) findViewById(R.id.my_edit_text)
// Setting the representation character to '$'
editText.setCharRepresentation('$');
// Logging the representation character
Log.i("Representation character", editText.getCharRepresentation());
// Setting the mask
editText.setMask("##/##/####");
// Logging the mask
Log.i("Mask", editText.getMask());

pt_BR

MaskedEditText é um EditText do Android com suporte a máscaras de texto customizáveis.

JAR

Se você quiser somente o arquivo jar ele está disponível aqui.

Como usar

Adicione xmlns:mask="http://schemas.android.com/apk/res/br.com.package.do.seu.app" à raíz do seu xml de layout. Agora você já pode usar o MaskedEditText! Basta inserir no local desejado em seu xml de layout:

<br.com.sapereaude.maskedEditText.MaskedEditText 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    mask:mask="###.###.###-##"
/>

Onde mask é a máscara do seu interesse e '#' é uma posição editável (que será substituída por um espaço em branco na tela).

Caso seja do seu interesse você pode mudar o caracter de representação (se você não quiser utilizar '#'):

<br.com.sapereaude.maskedEditText.MaskedEditText 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    mask:mask="ccc.ccc.ccc-cc"
    mask:char_representation="c"
/>

Você também pode mudar a máscara e o caracter de representação programaticamente:

MaskedEditText editText = (MaskedEditText) findViewById(R.id.meu_edit_text)
// Setando o caracter de representação para '$'
editText.setCharRepresentation('$');
// Logando o caracter de representação
Log.i("Caracter de representação", editText.getCharRepresentation());
// Setando a máscara
editText.setMask("##/##/####");
// Logando a máscara
Log.i("Mascara", editText.getMask());

maskededittext's People

Contributors

toshikurauchi avatar tuliomonteazul avatar denis1986 avatar jjhorgan avatar

Watchers

James Cloos avatar Michael Shrestha 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.