Android textwatcher倒计时
如何使textwatcher在键入时从250倒计时到0Android textwatcher倒计时,android,textwatcher,Android,Textwatcher,如何使textwatcher在键入时从250倒计时到0android:maxLength=“250”已设置,因此不会低于0 et_Notes = (EditText) dialog_list.findViewById(R.id.EditText_Notes); tvC = (TextView)dialog_list.findViewById(R.id.TextViewCounter); final TextWatcher mTextEditorWatcher = new TextW
android:maxLength=“250”
已设置,因此不会低于0
et_Notes = (EditText) dialog_list.findViewById(R.id.EditText_Notes);
tvC = (TextView)dialog_list.findViewById(R.id.TextViewCounter);
final TextWatcher mTextEditorWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
tvC.setText(String.valueOf(s.length()));
}
public void afterTextChanged(Editable s) {
}
};
et_Notes.addTextChangedListener(mTextEditorWatcher);
应用于它InputFilter.LengthFilter并将限制设置为250个字符,在方法
PostTextChanged
中将计数器设置为250-文本长度应用于它InputFilter.LengthFilter并将限制设置为250个字符,在方法PostTextChanged
中将计数器设置为250-文本长度tvC.setText(String.valueOf(250-s.length());在ontTextChanged中已经足够了。感谢您的想法!tvC.setText(String.valueOf(250-s.length());在ontTextChanged中已经足够了。感谢您的想法!