Note that there are some explanatory texts on larger screens.

plurals
  1. POautocomplete delay
    primarykey
    data
    text
    <p>I have an autocomplete in my application. There if I start entering letters autocomplete does not have time need a lot of time to process the JSON file. I use addTextChangedListener and because of this entering letters is not so smooth. I would like set a timeout before the search data in JSON. </p> <pre><code>Object mObj[] = { dep, arr }; for (int mI = 0; mI &lt; mObj.length; mI++) { ((AutoCompleteTextView) mObj[mI]) .addTextChangedListener(new TextWatcher() { public void onTextChanged(final CharSequence s, int start, int before, int count) { setListViewAuto(s, mass); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); } </code></pre> <p><strong>UPD:</strong> I do this:</p> <pre><code>final Object mObj[] = { dep, arr }; for (int mI = 0; mI &lt; mObj.length; mI++) { ((AutoCompleteTextView) mObj[mI]) .addTextChangedListener(new TextWatcher() { private Handler autoHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == MESSAGE_TEXT_CHANGED) { String enteredText = (String) msg.obj; setListViewAuto(enteredText); } } }; public void onTextChanged(final CharSequence s, int start, int before, int count) { massListAuto = new ArrayList&lt;String&gt;(Arrays .asList(mass)); String enteredText = s.toString(); autoHandler.removeMessages(MESSAGE_TEXT_CHANGED); final Message msg = Message.obtain(autoHandler, MESSAGE_TEXT_CHANGED, enteredText); autoHandler.sendMessageDelayed(msg, AUTOCOMPLETE_DELAY); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); } </code></pre> <p>But I get message: This Handler class should be static or leaks might occur</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload