[Solved] How to do a filtered select-option-like drop down in Android forms?


I suggest you a simple way cause you are new in android! add this function to your listView adapter:

public void filterList(String searchText)
{
    ArrayList<C_ChatListItem> temp = new ArrayList<>();
    adapteritems = backupItems; // copy your Get response in backupItems for new searches in constructor
                                // then in every new search retrieve adapterIems
    if(searchText != null && searchText.length() > 0)
    {
        for (int i = 0 ; i < adapteritems.size() ; i++)
        {
            if(adapteritems.get(i).users_entry.contains(searchText))
                temp.add(item);
        }
        adapteritems = temp;
    }
    notifyDataSetChanged();
}

And in your activity add a textWatcher to your search editText like this:

et_search.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            String txt = et_search.getText().toString();
            adapter.filterList(txt);
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    });

1

solved How to do a filtered select-option-like drop down in Android forms?