Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:36:39+00:00 2026-05-26T13:36:39+00:00

I have a ListView that I filter with and EditText that I have a

  • 0

I have a ListView that I filter with and EditText that I have a TextWatcher on to get the text change events. Everything works great until you delete the text out of edit text. The filter then just remains as the first letter and doesn’t go back to no filter.

What am I doing wrong? Here is the code for the TextWatcher, I even tried to disable the filter but that had no effect.

EditText txtFilter = (EditText) this.findViewById(R.id.txtFilter);
txtFilter.addTextChangedListener(new TextWatcher() {
    public void afterTextChanged(Editable s) {
        if(s.length()==0)
        {
            lv.setTextFilterEnabled(false);
        }
    }

    public void beforeTextChanged(CharSequence s, int start, int count, int after)
    {
    }

    public void onTextChanged(CharSequence s, int start, int before, int count)
    {
        lv.setTextFilterEnabled(true);
        lv.setFilterText(s.toString());
    }
});

Thanks for your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:36:39+00:00Added an answer on May 26, 2026 at 1:36 pm

    i think that Adil Soomro answer is bad … i just look at android source and setFilterText and it looks like

    public void setFilterText(String filterText) {
        // TODO: Should we check for acceptFilter()?
        if (mTextFilterEnabled && !TextUtils.isEmpty(filterText)) {
            createTextFilter(false);
            // This is going to call our listener onTextChanged, but we might not
            // be ready to bring up a window yet
            mTextFilter.setText(filterText);
            mTextFilter.setSelection(filterText.length());
            if (mAdapter instanceof Filterable) {
                // if mPopup is non-null, then onTextChanged will do the filtering
                if (mPopup == null) {
                    Filter f = ((Filterable) mAdapter).getFilter();
                    f.filter(filterText);
                }
                // Set filtered to true so we will display the filter window when our main
                // window is ready
                mFiltered = true;
                mDataSetObserver.clearSavedState();
            }
        }
    }
    

    so as you can see it’s setting adapter with filter …

    you should use lv.clearTextFilter(); instead of lv.setTextFilterEnabled(false);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF ListView that I am trying to filter within a BackgroundWorker.
I have a WPF ListView that is bound to a BindingList<T>. The binding works
I have a list that will filter in input in an EditText field and
I have a method that I want to use to filter a listview. I
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have a listview that is binded to a ThreadSafeObservableCollection. The background of each
I have a ListView that is set up with a MinHeight and a MaxHeight.
I have a ListView that I am populating with items from an ObservableCollection .
A have a ListView that is rendered with multiple items. Now I want to
I have a ListView that is populated using an XML file. However, I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.