[Android] Automatically format EditText that recognizes bank cards

Hits: 0

[Android] Automatically format EditText that recognizes bank cards

@Author GQ July 25th ,   2016 _

Find an EditText online that can automatically format bank card numbers,
Add a space every four digits
And according to the bank card number to determine the bank and card type of the bank card [local judgment: looks quite complete]
Thanks to the author, collect it~

Original github address

renderings

1. Using AndroidStudio

dependencies {

    compile 'com.yuyh.bankcardformat:library:1.0.1'

}

2. Use

  • JAVA code

tv = (TextView) findViewById(R.id.tv);
  editText = (BandCardEditText) findViewById(R.id.et);
  editText.setBankCardListener(new BandCardEditText.BankCardListener() {
      @Override
      public void success(String name) {
          tv.setText( "Bank: " + name);
      }

      @Override
      public void failure() {
          tv.setText( "Bank: " );
      }
  });

  • XML layout

<com.example.library.BandCardEditText
    android:id="@+id/et"
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:text="622700187301032701"
    android:background="#cccccc"/>

You may also like...

Leave a Reply

Your email address will not be published.