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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:41:46+00:00 2026-06-11T12:41:46+00:00

i need apply a filter for a ListView. I read a lot of documentation

  • 0

i need apply a filter for a ListView. I read a lot of documentation but i can’t understand the rule of the filter. The filter works but i don’t know what are it doing.

I use this class:

public class ArtistasActivity extends Activity {

private EditText filterText = null;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    View title = getWindow().findViewById(android.R.id.title);
    View titleBar = (View) title.getParent();
    titleBar.setBackgroundColor(Color.rgb(181, 9, 97));

    setContentView(R.layout.artistas_l);

    final ListView m_listview = (ListView) findViewById(R.id.listView1);

    ListAdaptor adaptor = new ListAdaptor(this, R.layout.artistas_l, loadArtistas());

    m_listview.setFastScrollEnabled(true);
    m_listview.setScrollingCacheEnabled(true);

    m_listview.setAdapter(adaptor);

    m_listview.setTextFilterEnabled(true);


    // Search

    filterText = (EditText) findViewById(R.id.search_box);
    filterText.addTextChangedListener(new TextWatcher() {

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                int arg3) {

        }

        public void afterTextChanged(Editable text) {
            Log.d("search", ""+text);
            ListAdaptor adaptor = (ListAdaptor) m_listview.getAdapter();
            adaptor.getFilter().filter(text);
            adaptor.notifyDataSetChanged();
        }
    });     

And ListAdaptor is typical:

    private class ListAdaptor extends ArrayAdapter<Artista> {
    private ArrayList<Artista> artistas;

    public ListAdaptor(Context context, int textViewResourceId, ArrayList<Artista> items) {
        super(context, textViewResourceId, items);
        this.artistas = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View v = convertView;

        if (v == null) {
            LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.artistas_list, null);
        }

        Object content = null;

        Artista o = artistas.get(position);

            TextView tt = (TextView) v.findViewById(R.id.ArtistTopText);

            tt.setText(o.getNombre());

            v.setClickable(true);
            v.setFocusable(true);
            v.setOnClickListener(myClickListener);


        return v;
    }
}

The aplications works, and when write in the texteditor the list is filtered but when i put a R, appear names with Dani or Diego…

I override the toString method for only return de name.

    @Override
public String toString() {
    return this.nombre;
}

Thx for help !! Rgds

  • 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-11T12:41:47+00:00Added an answer on June 11, 2026 at 12:41 pm

    There is no need to maintain the aristas array member, as you are already passing it to the super. In the getView method, get the item by calling getItem(position).. This correction will fix the problem..

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

Sidebar

Related Questions

Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
I need to apply tint effect on image in Android . But the tint
I am familiar with basic queries in SQL, but I need to apply a
in my application, I need to apply a blur-filter to an image. However, the
I apply a filter to Dataview and after that I need to get the
I have Bitmap. I want to apply median filter to my bitmap. But I
I need to re-apply filter when any data on the worksheet changes. Excel requires
How to apply a filter on CMRotationMatrix ? maybe kalman filter. I need fix
I need a list of URLs to apply filters to and at the moment
I need to apply validation on input time intervals that are taken in as

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.