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 8895835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:53:23+00:00 2026-06-14T23:53:23+00:00

While working on my first app I’d like to give the user the ability

  • 0

While working on my first app I’d like to give the user the ability to search the entries in a ListView (it’s in the UI-Thread).
For that, I added the SearchView into the Action Bar.

listView1.setTextFilterEnabled(true);

In an AsyncTask I set the Adapter to the listView:

protected void onPostExecute(boolean result) {
ListAdapter listadapter= new ArrayAdapter<String>(getApplicationContext(), R.layout.list_item, nameList);
listview1.setAdapter(listadapter);
}

Now the SearchView:

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);    
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(this);
return true;
[...]
}

Also I added these functions:

public boolean onQueryTextChange(String newText) {
    ListView listview1= (ListView) findViewById(R.id.mylist);
    listview1.setFilterText(newText);
    //mFilter.filter(newText);
    return false;
}

public boolean onQueryTextSubmit(String query) {
    ListView listview1= (ListView) findViewById(R.id.mylist);
    listview1.setFilterText(query);
}

Now the filtering is working fine, but this overlay with the searched char sequence is hiding the filtered data -> it doesn’t look well.

As I read everywhere, there’s no simple possibility to turn this overlay off.
So I changed my code a bit:

onPostExecute(blaaaaa) { [...]
     //Filter mFilter= = new ArrayAdapter<String>(getApplicationContext(), R.layout.list_item, nameList).getFilter();

and the two functions:

 //mFilter.filter(the_entered_text);
 ((ArrayAdapter<String>)listAdapter).getFilter().filter(query);
 ((ArrayAdapter<String>)listAdapter).notifyDataSetChanged();

My question is now, how can I let the listView get updated?
That “listview1.notifyDataSetChanged()” is no option for me, because it isn’t available for my ListAdapter.

EDIT: cast the adapter, as in an answer postet, now it works, but it filters so: entered text= “ka” -> all entries, which start with “ka” are displayed, not the ones which contain “ka”.

  • 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-06-14T23:53:24+00:00Added an answer on June 14, 2026 at 11:53 pm

    listview1.getAdapter().notifyDataSetChanged()

    Simples

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

Sidebar

Related Questions

I am working on an app that auto saves content while a user works
While working on my first app in Hibernate. While trying to retrieve a User
Working on my first FB app and making good progress. I know that non-testers
I am working on my first desktop app that queries LDAP. I'm working in
I'm currently working on an app that works with Twitter, but while developing/testing (especially
For a new SaaS app that I'm working on, I want the end user
I am working in an app in which I need to give feature like
I've been working on writing my first MVC3 application for a little while and
Somehow my iPhone Simulator is unable to play sounds. First an app I'm working
I am working with a silverlight app that has a fairly large appsettings section

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.