标签:style blog http io ar os java sp for
示例代码如下(代码全部写在adapter中):
private boolean programmaticalTextChange = false; private KeyEvent UnknownKey = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_UNKNOWN); holder.groupPwd.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { currentPwd=((EditText) v).getText().toString(); return false; } }); holder.groupPwd.addTextChangedListener(new MyTextWatcher(holder.groupPwd)); public class MyTextWatcher implements TextWatcher { private EditText editText; public MyTextWatcher(EditText editText) { this.editText = editText; } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!programmaticalTextChange) editText.dispatchKeyEvent(UnknownKey); } }
标签:style blog http io ar os java sp for
原文地址:http://blog.csdn.net/wode_dream/article/details/40895959