I am using text watcher on an edit text and that edit text is inside the list view. I have to call an method while edit text length == 3. But the text watcher events are executing more then one time. Here is my code :
holder.etTypeKeyword.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//System.out.println("KEYWORD TYPED : "+s+ " count : "+count);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if(s.length()==3){
// isServiceCall=true;
System.out.println("CALLING COUNT : " + position + " Length "+holder.etTypeKeyword.getText());
obKeywordSuggestionInterface.getKeywordUsingChar(s.toString(),position);
}else{
// isServiceCall=false;
}
}
});
Here is my log output where count message is repeating
>I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
I/System.out: CALLING COUNT : 2 Length
I/System.out: CALLING COUNT ACT : 2 Length Fun
Please some body please help me on this to restrict multiple execution of text watcher events. Thanks in advance.