开发者

Listener on AutoCompleteTextView (Android)

开发者 https://www.devze.com 2023-03-16 01:50 出处:网络
I have an Activity with an AutoCompleteTextView and a ListView with an adapter that extends BaseAdapter.

I have an Activity with an AutoCompleteTextView and a ListView with an adapter that extends BaseAdapter.

When the Activity starts and AutoCompleteTextView is empty, ListView show a full list of items. When user starts typing on AutoCompleteTextView and selects a hint, an OnItemClickListener launch and I call:

adapter.n开发者_高级运维otifyDataSetChanged();

This reloads the adapter with only some items. This works perfect, but when the user cleans the AutoCompleteTextView, nothing happens.

I want to associate a Listener that launches when the user cleans, without pressing Enter.

Are there any listener that do this?

Thanks!


you could provide your own implementation of TextWatcher interface that checks whether user input has been cleared and add it to you AutoCompleteTextBox using addTextChangedListener() method


Thanks wjeshak!!! Now works perfect.

This is the method that I've overrided, it can be useful for somebody :

@Override
public void onTextChanged(CharSequence s, int start, int before,int count) {
    if ( start == 0 && before == 1 && count == 0) {
        adapter.notifyDataSetChanged();
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消