标签:mystra android edittext beforetextchanged ontextchanged
本文地址:http://blog.csdn.net/caroline_wendy
EditText使用监听(Listener)addTextChangedListener时,会创建3个监听,注意使用方式,before在改变之前,on在改变时,after在改变之后。
如果在beforeTextChanged,则会缺少一个字符。
private EditText mTitleField; ...... mTitleField = (EditText)v.findViewById(R.id.crime_title); mTitleField.setText(mCrime.getTitle()); mTitleField.addTextChangedListener(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) { mCrime.setTitle(s.toString()); } @Override public void afterTextChanged(Editable s) { } });
标签:mystra android edittext beforetextchanged ontextchanged
原文地址:http://blog.csdn.net/caroline_wendy/article/details/40181409