【发布时间】:2016-11-05 17:39:47
【问题描述】:
我有一个包含两个编辑文本的活动,并且在该活动中有一个TextWatcher,它是单独实现的。我想创建一个实现TextWatcher 和那个TextWatcher 在编辑文本中的类。我怎样才能做到这一点
代码:-
private TextWatcher getmWatcher = 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) {
}
@Override
public void afterTextChanged(Editable s) {
checkFieldsForEmpty();
}
};
private TextWatcher mWatcher = 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) {
}
@Override
public void afterTextChanged(Editable s) {
checkFieldsForEmpty();
}
};
m_InputMobile = (EditText) findViewById(R.id.input_mobile);// finding Id of Mobile Number edit text
m_InputMobile.addTextChangedListener(getmWatcher);
m_InputPassword = (EditText) findViewById(R.id.input_password);// finding Id of assword editText
m_InputPassword.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);// defining password edit Tect Input type
【问题讨论】:
标签: android android-textwatcher