Android Edittext with auto detection of credit card type

后端 未结 3 1287
青春惊慌失措
青春惊慌失措 2021-02-04 17:31

I am dealing with payment option in android, By give an option to make a payment with credit card, some of the users may mistakenly choosing different credit card type for some

3条回答
  •  我在风中等你
    2021-02-04 17:58

    You would be watching the text as it is input, checking the first few digits to match the codes found here:

    http://www.stevemorse.org/ssn/List_of_Bank_Identification_Numbers.html

    This can be done with the TextWatcher listener Murtaza Hussain has pointed out.

    check the text via:

    switch (s.charAt(0)){
    case '4':
        // show visa symbol
        break;
    case '5':
        // show mastercard symbol
        break;
    ...
    

提交回复
热议问题