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

  • Home
  • SEARCH
  • 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 7968097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:01:24+00:00 2026-06-04T07:01:24+00:00

I have problem with filtering array adapter with custom object. I owerride custom object

  • 0

I have problem with filtering array adapter with custom object. I owerride custom object toString() so it returns name- which I want filter. Problem is that it filer correct count of items but wrong items. E.g. I have list with items a1,a2, b1,b2. When I enter b it filter and I see a1,a2. Here is my adapter code. I guess problem is there:

class CustomerAdapter extends ArrayAdapter<Customer> {

private LayoutInflater mInflater;
private List<Customer> customers;

public CustomerAdapter(Context context, int textViewResourceId,
        List<Customer> customers) {
    super(context, textViewResourceId, customers);
    mInflater = LayoutInflater.from(context);
    this.customers = customers;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.customers_list_item, null);

        holder = new ViewHolder();
        holder.text = (TextView) convertView
                .findViewById(R.id.textViewCustomerName);
        holder.icon = (LinearLayout) convertView
                .findViewById(R.id.linearLayoutCustomersListEdit);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    // Bind the data efficiently with the holder.
    holder.text.setText(customers.get(position).getCustomerName());

    return convertView;
}

static class ViewHolder {
    TextView text;
    LinearLayout icon;
}

}

Here is filter setup and call:

customerAdapter = new CustomerAdapter(this,
                R.layout.customers_list_item, repository.getCustomers());
setListAdapter(customerAdapter);

etSearch = (EditText) findViewById(R.id.editText_customers_search);
        etSearch.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int arg1, int arg2,
                int arg3) {
            customerAdapter.getFilter().filter(s.toString());
        }

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

        @Override
        public void afterTextChanged(Editable arg0) {
        }
    });

    getListView().setTextFilterEnabled(true);
  • 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-04T07:01:24+00:00Added an answer on June 4, 2026 at 7:01 am
    List<Customer> customers = new List<Customer>();
    List<Customer> tempcustomers = new List<Customer>();
    customers = repository.getCustomers();
    etSearch .addTextChangedListener(new TextWatcher() {
                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    // TODO Auto-generated method stub
                    System.out.println("onTextChanged Key presed..."+s);
    
    
                }
    
                @Override
                public void beforeTextChanged(CharSequence s, int start, int count,
                        int after) {
                    // TODO Auto-generated method stub
                    System.out.println("beforeTextChanged Key presed..."+filterText.getText());
    
                }
    
                @Override
                public void afterTextChanged(Editable s) {
                    // TODO Auto-generated method stub
                    System.out.println("afterTextChanged Key presed..."+filterText.getText());
                    if (!etSearch .getText().toString().equalsIgnoreCase("")){
                        tempcustomers = new List<Customer>();
                        String text = etSearch .getText().toString();
    
                        for(int i=0 ;i< customers .size();i++){
    
                            if(customers .get(i).toUpperCase().toString().contains(text.toUpperCase())){
                                tempcustomers .add(customers .get(i));
    
                            }
                        }
    
                            }
                        customerAdapter = new CustomerAdapter(this,
                    R.layout.customers_list_item,tempcustomers  );
    setListAdapter(customerAdapter);
    
                    }else{
                        customerAdapter = new CustomerAdapter(this,
                    R.layout.customers_list_item,customers  );
    setListAdapter(customerAdapter);
    
                    }
                }
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
I have a custom field, which its value is an wp array.. and I
I have an array of stdClass objects that are very simple, every object looks
I have problem with HTTP headers, they're encoded in ASCII and I want to
i have problem with libhid . i found that there 2 way 4 accessing
I'm new to MDX and have a problem regarding filtering out values from a
I have a CMS with a form-module, which generates an awful markup, that makes
I have a complex table pulled from a multi-ActiveRecord object array. This listing is
I have a linq-to-sql query that I use to fill an object that has
I am having problem filtering the mousePressEvent with installEventFilter MyTestxEdit is a widget that

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.