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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:15:05+00:00 2026-06-11T08:15:05+00:00

I have a small search implementation I am working on. A listView displays the

  • 0

I have a small “search” implementation I am working on. A listView displays the items if they match the query. This works fine, but whenever the menu is hidden and re-displayed and a new query is made, all the “searchables” continue to stack up. If i have 4 that should be displaying, first it would show 4, then 8, then 12, etc.

private class Adapter extends BaseAdapter {

    private LayoutInflater inflater;

    public Adapter(){
        inflater = LayoutInflater.from(getContext());
    }

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

    @Override
    public Object getItem(int position) {
        return menuItems.get(position).text;
    }

    @Override
    public long getItemId(int position) {
        return menuItems.get(position).id;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder = new ViewHolder(); 
            if (!isSearching) {
                convertView = inflater.inflate(R.layout.rbm_item, null);
            } else {
                convertView = inflater.inflate(R.layout.rbm_search_item, null);                 
            }
            holder.subMenuList = (LinearLayout) convertView.findViewById(R.id.sub_holder);
            holder.text = (TextView) convertView.findViewById(R.id.rbm_item_text);  

            convertView.setTag(holder);
            convertView.setOnClickListener(new OnClickListener() {
                @Override 
                public void onClick(View v) {
                    if (holder.subMenuList.getVisibility() == View.VISIBLE) {
                        holder.subMenuList.setVisibility(View.GONE);
                    } else {
                        holder.subMenuList.setVisibility(View.VISIBLE);
                    }
                }
            });

            if (isSearching) {
                holder.image = (ImageView) convertView.findViewById(R.id.rbm_item_icon);
                holder.image.setImageResource(menuItems.get(position).icon);    
                holder.chapterId = (TextView) convertView.findViewById(R.id.id_text);
                holder.chapterId.setText("Ch"+Integer.toString(menuItems.get(position).id));
            } else {
                holder.chapterId = (TextView) convertView.findViewById(R.id.rbm_item_id);
                holder.chapterId.setText(Integer.toString(menuItems.get(position).id));
            }
            holder.text.setText(menuItems.get(position).text);
            if (!isSearching) {
                for (int i=0;i<menuItems.get(position).subItems.size();i++) {
                    TextView tv = new TextView(ctx);
                    tv.setTextColor(0xFF893658);
                    tv.setText(menuItems.get(position).subItems.get(i).getTitle());
                    tv.setCompoundDrawablesWithIntrinsicBounds(menuItems.get(position).subItems.get(i).getIcon(), 0, 0, 0);
                    tv.setCompoundDrawablePadding(5);
                    if (i == 0) {
                        if (menuItems.get(position).subItems.size() == 1) {
                            tv.setPadding(20, 20, 0, 20);
                        } else{
                            tv.setPadding(20, 20, 0, 10);
                        }
                    } else if (i == menuItems.get(position).subItems.size()-1){
                        tv.setPadding(20, 10, 0, 20);
                    } else {
                        tv.setPadding(20, 10, 0, 10);
                    }
                    holder.subMenuList.addView(tv);
                }
            } 

        return convertView;
    }

    class ViewHolder {
        TextView text;
        ImageView image;
        LinearLayout subMenuList;
        TextView chapterId;
    }           
}
  • 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-11T08:15:07+00:00Added an answer on June 11, 2026 at 8:15 am

    try to clear the listitems that are in the menuItems and then add the items back after the new query is made.
    Is the try to clear the listitems that are in the menuItems and then add the items back after the new query is made a arraylist or something?

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

Sidebar

Related Questions

I have a small issue on a search form. PLease check this: http://www.fortisfitness.ca/test/script.php What's
We have a small data set and would like to search through it in
I have a small application in java which searches images using bing image search.
I have small query today I happen to see when I typed a website
I have small script in bash, which is generating graphs via gnuplot. Everything works
I have a search field whose original width is small (because it looks better
i want to implement a small search engine , i have index page where
I have a small question regarding rails. I have a search controller which searches
I have a small screen program which displays patients at the top there is
I used to have a small chat app(which was almost working), that uses PHP,

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.