tags:

views:

80

answers:

1

Hi, I actually had a multiautocompletetextview, where i call host after 3 characters to have a dynamic search list. But if the user put others characters, my code call host for each of them. So it must be very long.

Could I wait a moment (about 500 ms) before launching the action , in order to look if user do an action or not ? that's possible ?

A: 

You could use a separeted thread. When the user entered the text you could create a thread, make it sleep for 500ms and when it will wake up check if the text typed is changed.

EDIT

Create a Handler

private Handler h = new Handler();

Create a runnable that makes your dynamic search

private Runnable myrunnable = new Runnable() {
   public void run() {
       ....
};

Then call your runnable in onTextChanged like

h.postDelayed(myrunnable, 500);

see Handler for more options/informations

Make sure that your threads will access the memory in a consistent way!

hara
thx a lot, it works fine
Nanis