Android Edittext with auto detection of credit card type

后端 未结 3 1289
青春惊慌失措
青春惊慌失措 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 18:02

    There is no native functionality for that. You have to set TextWatcher class on EditText. What it does is set a listener on your field and as you type it gives you method to check the input.

    yourEditText.addTextChangedListener(new TextWatcher() {
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
    
                    // TODO Auto-generated method stub
                }
    
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
                    // TODO Auto-generated method stub
                }
    
                @Override
                public void afterTextChanged(Editable s) {
    
                    //Check your Credit Card Number here.
    
                }
    
    
       });
    

提交回复
热议问题