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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:37:53+00:00 2026-06-03T06:37:53+00:00

I’ve have a Vector like this in my app: Vector<Firm> firmVector= new Vector<Firm>(); As

  • 0

I’ve have a Vector like this in my app:

  Vector<Firm> firmVector= new Vector<Firm>();

As you may see, this is a vector of objects from my own class Firm

So to my question, is it possible to add a AutoComplete to this `Vector?

Like this one, from developer.android.com:

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.autocomplete_country);
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES);
  textView.setAdapter(adapter);
}
  • 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-03T06:37:54+00:00Added an answer on June 3, 2026 at 6:37 am

    Yes, you can do it by implementing an ArrayAdapter, but you’ll need to implement the getFilter() which is used by the AutoCompleteTextView. Something similar to this might work:

        private class FirmAdapter extends ArrayAdapter<Firm> {
    private Filter filter;
            @Override
            public Filter getFilter() 
            {
                if(filter == null){
                    filter = new Filter(){
                        int lastlen = 0;
                        boolean initialized = false;
    
                        @SuppressWarnings("unchecked")
                        @Override
                        protected void publishResults(CharSequence constraint, FilterResults results)
                        {
                            filteredItems = (List<Firm>)results.values;
                            ArrayAdapter.this.notifyDataSetChanged();
                        }
    
                        @Override
                        protected FilterResults performFiltering(CharSequence constraint)
                        {
                            FilterResults results = new FilterResults();
                            if(constraint == null || constraint.length() == 0){
                                results.values = null;
                            }else{
                                String val;
                                Firm obj;
                                constraint = constraint.toString().toUpperCase();
                                int newlen = constraint.length();
                                LinkedList<Firm> filteredResults = new LinkedList<Firm>();
                                if(newlen < lastlen){
                                    int i = 0, size = ArrayAdapter.super.getCount();
                                    for(i=0;i<size;i++){
                                        obj = ArrayAdapter.super.getItem(i);
                                        val = obj.toString(); // CUSTOMIZE THIS
                                        if(val.contains(constraint)) filteredResults.add(obj);
                                    }
                                }else{
                                    int i = 0, size = getCount();
                                    for(i=0;i<size;i++){
                                        obj = getItem(i);
                                        val = obj.toString(); // CUSTOMIZE THIS
                                        if(val.contains(constraint)) filteredResults.add(obj);
                                    }
                                }
                                lastlen = newlen;
                                results.values = filteredResults;
                            }
                            return results;
                        }
                    };
                }
                return filter;
            }
        }
    }
    

    I ripped this out of a project I have, so it will need some testing and cleanup to get working (in my case I have a Filter on a set of JSONObject instances, where you have a Firm) but try something like that. The comments with CUSTOMIZE THIS are where you want to actually perform the test based on the input into the AutoCompleteTextView.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have some data like this: 1 2 3 4 5 9 2 6
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.