Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onKeyDelete 回调的是 inputComplete #26

Open
iostyle opened this issue Oct 21, 2019 · 2 comments
Open

onKeyDelete 回调的是 inputComplete #26

iostyle opened this issue Oct 21, 2019 · 2 comments

Comments

@iostyle
Copy link

iostyle commented Oct 21, 2019

No description provided.

@iostyle
Copy link
Author

iostyle commented Oct 21, 2019

// 监听删除
private void onKeyDelete() {
for (int i = mPwdTextViews.length - 1; i >= 0; i--) {
PwdTextView tv = mPwdTextViews[i];
if (!tv.getText().toString().trim().equals("")) {
if (mEtPwd) {
tv.clearPwd();
}
tv.setText("");
// 添加删除完成监听
tv.setBackgroundDrawable(mEtBackgroundDrawableFocus);
if (i < mEtNumber - 1) {
mPwdTextViews[i + 1].setBackgroundDrawable(mEtBackgroundDrawableNormal);
}
if (inputCompleteListener != null) {
inputCompleteListener.deleteContent();
}
break;
}
}
}

@iostyle
Copy link
Author

iostyle commented Oct 21, 2019

private class MyTextWatcher implements TextWatcher {

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable editable) {
        String inputStr = editable.toString();
        if (!TextUtils.isEmpty(inputStr)) {

            char[] strArray = inputStr.toCharArray();

            for (int i = 0; i < strArray.length; i++) {

                // 不能大于输入框个数
                if (i > mEtNumber) {
                    break;
                }
                setText(strArray[i] + "");
                et.setText("");
            }
        }
    }
}

解决inputComplete调用两遍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant