Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mEdtPaymentAuthorCreditExpirationDate.addTextChangedListener(new ExpirationDateFormatWatcher());
- package com.donateen.app.view;
- import android.text.Editable;
- import android.text.TextWatcher;
- public class ExpirationDateFormatWatcher implements TextWatcher {
- private int mLength;
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- mLength = charSequence.length();
- }
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- }
- @Override
- public void afterTextChanged(Editable editable) {
- int currentLength = editable.length();
- boolean ignoreBecauseIsDeleting = false;
- if (mLength > currentLength) {
- ignoreBecauseIsDeleting = true;
- }
- if (ignoreBecauseIsDeleting) {
- return;
- }
- if (editable.length() == 2 && !editable.toString().contains("/")) {
- editable.insert(editable.length(), " / ");
- }
- }
- }
Add Comment
Please, Sign In to add comment