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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:01:05+00:00 2026-05-23T15:01:05+00:00

I have a AutoCompleteTextView and a custom AutoCompleteTextView adapter. my list has 20 items

  • 0

I have aAutoCompleteTextView and a custom AutoCompleteTextView adapter.

my list has 20 items and All items contains “vodafone” string. When i type one character in AutoCompleteTextView, it shows the results and on second, it does not shows the list. For example;

<br/>->V
<br/>-->AutoComplete DropDown menu appears
<br/>->Vo
<br/>-->AutoComplete DropDown disappears
<br/>->Vod
<br/>-->AutoComplete DropDown menu appears
<br/>->Voda
<br/>-->AutoComplete DropDown disappears
<br/>...etc

Why it’s happening? Any suggestions?

here is my adapter:

package listadapters;

import java.util.ArrayList;
import java.util.Locale;

import objects.Item;
import utils.Logging;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
public class AutoCompleteTextAdapter2 extends BaseAdapter implements Filterable {

   Context _context;
   ArrayList<Item> _items = new ArrayList<Item>();

   public AutoCompleteTextAdapter2(Context context, ArrayList<Item> items) {

       _context = context;


       for (int i = 0; i < items.size(); i++) {
           _items.add(new Item(items.get(i)));
        }

       for (int i = 0; i < _items.size(); i++) {
            orig.add(new Item(_items.get(i)));
        }
       filter = new ItemFilter();

   }

   @Override
   public int getCount() {
       if (_items != null)
           return _items.size();
       else
           return 0;
   }

   @Override
   public Object getItem(int arg0) {
       return _items.get(arg0);
   }

   @Override
   public long getItemId(int arg0) {

       return 0;
   }

   @Override
   public View getView(int arg0, View arg1, ViewGroup arg2) {

       View gv;

       if (arg1 == null){

           gv = new View(_context);
       }else {
           gv = (View) arg1;
       }
       return gv;
   }



  @Override

  public Filter getFilter() {

      return filter;

  }

  private ItemFilter filter;

  ArrayList<Item> orig = new ArrayList<Item>();

  private class ItemFilter extends Filter {

      public ItemFilter() {

  }

  ArrayList<Item> results = new ArrayList<Item>();
  @Override
  protected FilterResults performFiltering(CharSequence constraint) {

      if(constraint != null)
          Logging.TraceMessage(constraint.toString(), "**", "1");
      FilterResults oReturn = new FilterResults();

      if (orig == null){
        for (int i = 0; i < _items.size(); i++) {
            orig.add(new Item(_items.get(i)));
        }
      }

      if (constraint != null){
          results.clear();
          if (orig != null && orig.size() > 0) {
              for (Item i : orig) {
                  if (i._itemName.toLowerCase(Locale.US).contains(constraint.toString().toLowerCase(Locale.US))){
                      results.add(new Item(i));
                  }
              }
          }
          Logging.TraceMessage(String.valueOf(results.size()), "**", "2");
          oReturn.values = results;
      }
      return oReturn;
  }


  @SuppressWarnings("unchecked")
  @Override
  protected void publishResults(CharSequence constraint, FilterResults results) {
      _items.clear();
      for(int i = 0; i < ((ArrayList<Item>)results.values).size(); i++){
          _items.add(new Item(((ArrayList<Item>)results.values).get(i)));
      }
      notifyDataSetChanged();
  }

}

 }

and set adapter code:

 AutoCompleteTextAdapter2 adapter = new AutoCompleteTextAdapter2(myAct, GlobalVariables.currCategoryItems);
yeniMarkaModel.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-05-23T15:01:06+00:00Added an answer on May 23, 2026 at 3:01 pm

    You MUST assign the number of items you filtered to the FilterResults.count before you return your results. The text control allocates this many lines for the drop-down.

    The reason for this is that the AutoCompleteTextView never uses the values field directly but rather asks your Adapter to fetch an item with a specific index. This makes it possible, for instance, to always pass the whole collection of items to values but only return some of them from Adapter.getItem().

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

Sidebar

Related Questions

I have an AutoCompleteTextView with a MatrixCursor as an adapter. The AutoCompleteTextView has a
I have an AutoCompleteTextView and want to limit the number of dropdown items visible
Right now I have a list activity powered by a cursor adapter. I have
I have an AutoCompleteTextView which works with a list of cities. The list is
I have an Activity with an AutoCompleteTextView and a ListView with an adapter that
I have created a custom view by extending AutoCompleteTextView (with a specialized function called
I have an AutoCompleteTextView control serviced by an 'OnClick' Listener. It extracts a list
Does anyone know if it's possible to have the adapter for an AutoCompleteTextView search
I have an AutoCompleteTextView which is using an ArrayAdapter<android.location.Address> as its Adapter . The
In my activity, I have an AutoCompleteTextView that gets its contents from my custom

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.