相关疑难解决方法(0)

TextWatcher用于多个EditText

我想TextWatcher为多个EditText字段实现接口.目前我正在使用:

text1.addTextChangedListener(this);
text2.addTextChangedListener(this);
Run Code Online (Sandbox Code Playgroud)

然后重写我的Activity中的方法:

public void afterTextChanged(Editable s) {}

public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) 
{
 // do some operation on text of text1 field
 // do some operation on text of text2 field 
}
Run Code Online (Sandbox Code Playgroud)

然而,这工作正常但我正在寻找其他方法,以便我可以明确地确定当前关注的EditText字段SoftKeyboard.

android interface textwatcher android-edittext android-activity

65
推荐指数
5
解决办法
7万
查看次数