-1

我想对多个EditText设置监听事件,但看起来好像一次只能绑定一个资源,我知道OnClick方法可以绑定多个资源id,但EditText 好像不行,我不确定想问一下各位,英文不好请见谅

I'd like to set up listening events for multiple EditTexts, but it looks like I can only bind one resource at a time. I know the OnClick method can bind multiple resource ids, but EditText doesn't seem to work. I'm not sure I want to ask you, but I'm sorry for the English.

@OnTextChanged(**R.id.et_account ,R.id.et_password** , callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterTextChanged(Editable s) {

    if (TextUtils.isEmpty(etPassword.getText().toString())) {
        ivCleanPassword.setVisibility(View.GONE);
        iv_eye.setVisibility(View.GONE);
    } else {
        ivCleanPassword.setVisibility(View.VISIBLE);
        iv_eye.setVisibility(View.VISIBLE);
    }
    if (TextUtils.isEmpty(etAccount.getText().toString())) {
        ivCleanAccount.setVisibility(View.GONE);
    } else {
        ivCleanAccount.setVisibility(View.VISIBLE);
    }
}
FM1024
  • 173
  • 1
  • 7
  • 1
    Hey you can use online translator to convert it to english. We can make grammatically correct. But please post your question in english – Pankaj Kumar Aug 26 '18 at 15:39

1 Answers1

0

Technically it’s possible:

@OnTextChanged({R.id.edittext1, R.id.edittext2})

but it’s a bit problematic because it’s hard to determine which view triggered the call.

For discussion on this topic see https://github.com/JakeWharton/butterknife/issues/672

algrid
  • 5,600
  • 3
  • 34
  • 37