Hi
I've a multiAutocompleteTextView which I load the adapter list by calling Host. That is to say, when the user write 3 letters in the searchZone, I call Host, and I propose him suggestions in relation to what he write.
I would like to temporize this call. If user write more that 3 letters, The purpose is to wait the end before launch call. (I fell that after 500 ms of inactivity it is the end)
So I use an Handler to do that, but it doesn't work. Either it dosen't do the call, Or it do it but after each letters :/
My code
On the OnCreate :
searchZone.setOnItemClickListener(this);
// lISTENER key pressed on ZoneOK+multiauocompletetextview
searchZone.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
[...]
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int count, int after) {
try {
if (s.length() >= searchZone.getThreshold()) {
try{
timerHandler.removeCallbacks(callHostToLoadSuggest);
}catch(Exception e){
timerHandler = new Handler();
}
// Display Suggestions
search_pattern = searchZone.getText().toString();
timerHandler.postDelayed(callHostToLoadSuggest, 500);
} catch (Exception e) {
Alerts.showAlert(e.toString(), HeaderMailDisplayActivity.this, true);
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
the Runnable :
final Runnable callHostToLoadSuggest = new Runnable() {
public void run() {
displaySuggest(search_pattern);
}};
Did someone could help me please ? I try to do that for 1 month :/