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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:13:21+00:00 2026-06-01T19:13:21+00:00

I have this Autocomplete class and I am modifying the adapter so that, instead

  • 0

I have this Autocomplete class and I am modifying the adapter so that, instead of just text, it will show an icon in front of the text that appears. All the choices available are stored in an array of strings.

Now, for some reason, it only shows 5 items no matter what I type.

public class AutoCompleteText extends Activity{

public class CustomAdapter extends ArrayAdapter<String>{

    public CustomAdapter(Context context, int textViewResourceId,String[] objects) {
        super(context, textViewResourceId, objects);
    }

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

        LayoutInflater inflater = getLayoutInflater();
        View row = inflater.inflate(R.layout.arow,parent, false);
        TextView label = (TextView) row.findViewById(R.id.element);
        label.setText(listItems[position]);
        ImageView icon = (ImageView) row.findViewById(R.id.image);

        if("Item1".equals(listItems[position])|| something else || something else){
            icon.setImageResource(R.drawable.img1);
        }
        else if("Item2".equals(listItems[position])|| something else || something else){
            icon.setImageResource(R.drawable.img2);
        }
        else if("Item3".equals(listItems[position])|| something else || something else){
            icon.setImageResource(R.drawable.img3);
        }
        else if("Item4".equals(listItems[position])|| something else || something else){
            icon.setImageResource(R.drawable.img4);
        }
        else if("Item5".equals(listItems[position])|| something else || something else){
            icon.setImageResource(R.drawable.img5);
        }
        else if("Item6".equals(listItems[position])|| something else || something else) {
            icon.setImageResource(R.drawable.img6);
        }
        else{
            icon.setImageResource(R.drawable.whatever);
        }
        return row;
    }
}


AutoCompleteTextView acTextView;
private static String listItems[] = { "Item1", "Item2","Item3","Item4","Item5", "Item6", "Item7", "Item8", "Item9", "Item10"
                                        "Item11", "Item12","Item13","Item14","Item15", "Item16", "Item17", "Item18", "Item19", "Item20");

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

    acTextView = (AutoCompleteTextView)findViewById(R.id.searchfield);
    acTextView.setThreshold(1);
    acTextView.setAdapter(new CustomAdapter(AutoCompleteText.this,R.layout.arow, listItems));
    acTextView.setOnItemClickListener(new OnItemClickListener(){
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                try {
                    //random staff
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
            } 
        }

    );
}   

}

the app compiles and runs fine without any errors. Can anyone help me on this?
Thank you.

  • 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-01T19:13:22+00:00Added an answer on June 1, 2026 at 7:13 pm

    don’t compare Strings with == since that checks if it is the same Object not the same text. Use .equals instead.

    if ("Item6".equals(listItems[position]) { 
    

    It might work in your case since the compiler might be smart enough to use the same object to represent the text but it’ usually not a good idea.

    Also you just have 5 (+default) items in your code. Do you see those?

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

Sidebar

Related Questions

I have this code: $(#xyz).unautocomplete().autocomplete(dataVar, { minChars: 0, width: 400, matchContains: true, highlightItem: true,
Currently, I have this version of the autocomplete control working when returning XML from
I have a huge autocomplete field with a list of exams. This field prepends
This other SO question asks about an autocomplete textbox in WPF. Several people have
I have a problem with using facet. I need autocomplete and for this I
We have this software that has a webservices component. Now, the administrator of this
I have some class like this <div class = student> <div class = name>Adam
I have this simple form: class PagoDesde(forms.Form): from django import forms as f desde
I installed this gem: https://github.com/crowdint/rails3-jquery-autocomplete and applied it successfully: class TagsController < ApplicationController autocomplete
I have an Activity with an AutoComplete box on it. Whenever the text changes,

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.