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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:08:14+00:00 2026-06-08T00:08:14+00:00

I am extending the Array Adapter as it follows but I get still the

  • 0

I am extending the Array Adapter as it follows but I get still the old results can you please tell me what is the problem ?

public class Adaptor extends ArrayAdapter<String> implements Filterable{

        private ArrayList<String> items;

        public Adaptor(Context context, int textViewResourceId, String[] objects) {
            super(context, textViewResourceId, objects);
            items = new ArrayList<String>();
            for (int i = 0; i < objects.length ; i++)
                items.add(objects[i]);

        }


        @Override
        public int getCount() {
            return items.size();
        }


        @Override
        public String getItem(int position) {
            return items.get(position);
        }

        @Override
        public Filter getFilter() {
            Filter myFilter = new Filter(){

                @Override
                protected FilterResults performFiltering(CharSequence arg0) {
                    FilterResults rezultate = new FilterResults();
                    ArrayList<String> chestii = new ArrayList<String>();
                    for (int i = 0; i < items.size() ; i++)
                    {
                        String tmp = items.get(i).toUpperCase();
                        if (tmp.startsWith(arg0.toString().toUpperCase()))
                                chestii.add(items.get(i));

                    }
                    rezultate.count = chestii.size();
                    rezultate.values = chestii;
                    return rezultate;
                }

                @Override
                protected void publishResults(CharSequence constraint,
                        FilterResults results) {
                    if (results != null && results.count > 0)
                    {
                        notifyDataSetChanged();
                    }
                    else notifyDataSetInvalidated();

                }

            };
            return myFilter;
        }




    }
  • 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-08T00:08:15+00:00Added an answer on June 8, 2026 at 12:08 am

    Your list contains items from “items” and you don’t modify items in it, you have to remove positions from “items” and then call notifyDataSetChange, to restore lately all items you have to save previous items

    this is works fine:

    /**
     * Adapter wrapper to represent list of dialogs
     * @author Ryazantsev Dmitry
     * @email dilix90@gmail.com 2012
     */
    public class FriendsAdapter extends ArrayAdapter<User>
    {
        private final LayoutInflater inflater;
        private final ImageLoader il;
        private Context parentContext;
        private List<User> mData;
        private List<User> mOriginalData;
        public SimpleImageLoader sil;
    
        @Override
        public void add(User object)
        {
            if (mOriginalData != null)
                mOriginalData.add(object);
            else
                mData.add(object);
        }
    
        @Override
        public void remove(User object)
        {
            if (mOriginalData != null)
                mOriginalData.remove(object);
            else
                mData.remove(object);
        }
    
        @Override
        public int getCount()
        {
            return mData.size();
        }
    
        @Override
        public User getItem(int position)
        {
            return mData.get(position);
        }
    
        @Override
        public int getPosition(User item)
        {
            return mData.indexOf(item);
        }
    
        public FriendsAdapter(Context context, int textViewResourceId, List<User> objects)
        {
            super(context, textViewResourceId, objects);
            Log.v("refresh", context + " " + textViewResourceId + " " + objects);
            parentContext = context;
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            il = new ImageLoader(context);
            mData = objects;
            sil = new SimpleImageLoader(context, true, 64);
            sil.setOnUiThread(false);
        }
    
        /**
         * We have a custom view and need to organize it
         */
        @Override
        public View getView(final int position, View convertView, final ViewGroup parent)
        {
    
            ViewHolder holder;
            if (convertView == null)
            {
                convertView = inflater.inflate(R.layout.friends_list_row, null);
                holder = new ViewHolder();
                holder.name = (TextView) convertView.findViewById(R.id.friendName);
                holder.root = convertView.findViewById(R.id.root);
                holder.photo = (ImageView) convertView.findViewById(R.id.friendPhoto);
                holder.online = (ImageView) convertView.findViewById(R.id.online);
                convertView.setTag(holder);
            }
            else
                holder = (ViewHolder) convertView.getTag();
    
            User user = getItem(position);
            holder.online.setVisibility(user.isOnline() > 0 ? View.VISIBLE : View.GONE);
            if (user != null)
            {
                holder.name.setText(user.getFIO());
                holder.photo.setTag(user.getPhotoUrl());
                if (user.getPhotoBitmap() != null)
                    holder.photo.setImageBitmap(user.getPhotoBitmap());
                else
                {
                    holder.photo.setImageResource(R.drawable.contact_nophoto);
                    sil.displayImageUserAttach(holder.photo, user.getPhotoUrl(), user, null, false, null);
                }
            }
    
            // parent.setVisibility(position % 2 == 0?View.GONE:View.VISIBLE);
            return convertView;
        }
    
        private static class ViewHolder
        {
            public TextView name;
            public ImageView photo;
            public View root;
            public View online;
        }
    
        @Override
        public Filter getFilter()
        {
            return new Filter()
            {
                @SuppressWarnings("unchecked")
                @Override
                protected void publishResults(CharSequence constraint, FilterResults results)
                {
                    Log.v("filter", "filter finished");
                    mData = (List<User>) results.values;
                    if (results.count > 0)
                    {
                        notifyDataSetChanged();
                    }
                    else
                    {
                        notifyDataSetInvalidated();
                    }
                }
    
                @Override
                protected FilterResults performFiltering(CharSequence constraint)
                {
                    Log.v("filter", "filter perform");
                    if (mOriginalData == null)
                        mOriginalData = new ArrayList<User>(mData);
                    List<User> result;
                    FilterResults r = new FilterResults();
                    if (constraint == null || constraint.length() <= 0)
                        result = new ArrayList<User>(mOriginalData);
                    else
                    {
                        result = new ArrayList<User>();
                        for (int i = 0; i < mOriginalData.size(); i++)
                            if (constraint.length() > 0
                                    && mOriginalData.get(i).getFIO().toLowerCase()
                                            .contains(constraint.toString().toLowerCase()))
                                result.add(mOriginalData.get(i));
                    }
                    r.values = result;
                    r.count = result.size();
                    return r;
                }
            };
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm extending a constructor class' functionality via the prototype method, but I'm having trouble
I'd like to make a class extending the numpy array base type, class LemmaMatrix(numpy.ndarray):
I'd like to create my own class extending array of ints. Is that possible?
I'm having trouble extending a base class that extends Ordered[Base]. My derived class can't
I have a class that is already extending TabActivity so i can't extend ListActivity.
Im extending the UIButton Class to be able to set the font and color
I'm extending AbstractJavaSamplerClient and creating a custom Java Sampler. It's all working good but
I am extending the ActionResult class. In the ExecuteResult method I want to check
I am extending the ItemsControl ( class EnhancedItemsControl : ItemsControl ), because I want
I have got a main extending adapter which adds rows when user clicks on

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.