У меня есть один редактируемый текст в адаптере, я прикрепил к нему addTextChangedListener, и все его методы вызывались несколько раз.
Методы TextWatcher вызываются несколько раз
Ответы (1)
ИЗМЕНИТЬ Использование таймера для отмены обработки, пока пользователь печатает
Вы можете попробовать добавить таймер для обработки вашего текста и отменить эту обработку, пока пользователь печатает.
private Timer timer;
myButton.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable arg0) {
// user typed: start the timer
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// do your actual work here
}
}, 600); // 600ms delay before the timer executes the „run“ method from TimerTask
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// nothing to do here
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// user is typing: reset already started timer (if existing)
if (timer != null) {
timer.cancel();
}
}
});
Надеюсь, поможет !
person
Maxouille
schedule
18.09.2018
Я реализовал метод afterTextChanged
- person Sne; 18.09.2018
держатель.etOther.addTextChangedListener (новый TextWatcher() { String ans=;@Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { ans=arrayList.get(finalI1).getAnswer();}@Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}@Override public void afterTextChanged(Editable editable) { arrayList.get(finalI1).setAnswer(ans+ +editable.toString());}});
- person Sne; 18.09.2018
onCreateViewHolder()
. - person Piyush   schedule 18.09.2018