小编Nis*_*hal的帖子

TextWatcher的onTextChanged方法中的count参数对于输入类型为textWebPassword的EditText无法正常工作

TextWatcher的onTextChanged方法中的count参数对于输入类型为textWebPassword的EditText无法正常工作。即使EditText中有超过1个字符,else if(count == 1)中的代码也正在运行。

public class Test extends AppCompatActivity {
private EditText ePassword;
private TextView tPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);
    tPassword = (TextView) findViewById(R.id.textView_password);
    ePassword = (EditText) findViewById(R.id.editText_password);
    ePassword.addTextChangedListener(textWatcherPassword);


}
private TextWatcher textWatcherPassword = new 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) {

        if (count == 0) {
            // start fade out animation
            tPassword.setAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out));
            //Make the …
Run Code Online (Sandbox Code Playgroud)

android textwatcher android-edittext android-inputtype

1
推荐指数
2
解决办法
2649
查看次数