EditText设置文字改变时的监听

textWatcher = new TextChangeWatcher();

etQuerryInfo.addTextChangedListener(textWatcher);

/**
* 文字改变类,文字改变时的监听
*/
private class TextChangeWatcher implements TextWatcher{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
rlQuerryInfo.setVisibility(View.VISIBLE);
tvQuerryKey.setText(etQuerryInfo.getText().toString());
} @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override
public void afterTextChanged(Editable s) { }
}

实现TextWatcher三个方法即可onTextChanged,beforeTextChanged,afterTextChanged

上一篇:postGreSQL数据库部署及简单使用


下一篇:linuxmint计算器