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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:50:44+00:00 2026-06-17T15:50:44+00:00

The ExpandableListView is almost empty. I don’t really know what is wasting so much

  • 0

The ExpandableListView is almost empty. I don’t really know what is wasting so much memory.
After heavy scrolling (ca 60 times up and down) the app stops responding. I did some research and found out that this error occurs just with targetSdkVersions 8 to 13. Everything is fine with Version 14 and higher.
My App uses the android support library v4 and ViewPagerIndicator for the ViewPager.
Is this a nasty bug, or is something wrong with my code?

package com.test.test;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;

import com.viewpagerindicator.TabPageIndicator;

public class MainActivity extends Activity{

    public ExpandableListAdapter mAdapter;  
    final String[] page_titles = new String[]{"page1","page2"}; 


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    
        setContentView(R.layout.main_activity);

        //Instantiating the adapter
        myAdapter mAdapter = new myAdapter(this);

        //instantiate the Views
        ViewPager mPager = (ViewPager)findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);

        TabPageIndicator mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
        mIndicator.setViewPager(mPager);              
    }

    private class myAdapter extends PagerAdapter{
        Context context;

        public myAdapter(Context c){
            this.context = c;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return page_titles.length;
        }

        @Override
        public boolean isViewFromObject(View v, Object o) {
            // TODO Auto-generated method stub
            return v.equals(o);
        }

        public CharSequence getPageTitle(int position) {
            return page_titles[position];
        }

        public Object instantiateItem(View pager, int position) {
            final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            View v = inflater.inflate(R.layout.expander, null, false);
            ExpandableListView elv1 = (ExpandableListView) v.findViewById(R.id.elv1);

            MainActivity.this.mAdapter = new BaseExpandableListAdapter() {

                @Override
                public Object getChild(int groupPosition, int childPosition) {
                    return null;
                }

                @Override
                public long getChildId(int groupPosition, int childPosition) {
                    return 0;
                }

                @Override
                public int getChildrenCount(int groupPosition) {
                    return 1;                                       
                }

                @Override
                public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
                    View v = inflater.inflate(R.layout.childview, null, false);

                    return v;
                }

                @Override
                public Object getGroup(int groupPosition) {
                    return null;
                }

                @Override
                public int getGroupCount() {
                    return 20;
                }

                @Override
                public long getGroupId(int groupPosition) {
                    return 0;
                }

                @Override
                public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
                    View v = inflater.inflate(R.layout.twolinelistitem, parent, false);                                                                                                                                                                                 
                    return v;
                }

                @Override
                public boolean hasStableIds() {
                    return false;
                }

                @Override
                public boolean isChildSelectable(int groupPosition, int childPosition) {
                    return false;
                }
            };
            elv1.setAdapter(MainActivity.this.mAdapter);

            ((ViewPager) pager).addView(v, 0);
            return v;                                   
        }

        @Override
        public void destroyItem(View pager, int position, Object view) {
            ((ViewPager) pager).removeView((View) view);
        }

        @Override
        public void finishUpdate(View view) {
        }

        @Override
        public void restoreState(Parcelable p, ClassLoader c) {
        }

        @Override
        public Parcelable saveState() {
            return null;
        }

        @Override
        public void startUpdate(View view) {
        }

    }



}
  • 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-17T15:50:46+00:00Added an answer on June 17, 2026 at 3:50 pm

    inflating a layout it very memory intensive, you need to find a way to not do this for every list item, use a view holder class or only inflate if pager is null.

    a view holder would look like this:

    private static class ViewHolder {
        public LinearLayout linearLayout;
    }
    

    and you would store your layout like this

    ViewHolder holder = new ViewHolder();
    holder.linearLayout = (LinearLayout) convertView.findViewById(R.id.expander);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is the ExpandableListView but it only supports up to 2 levels.
I'm trying to make an Expandable ListView, but I don't know how to retrieve
After I put my ExpandableListView component in a ViewFlipper element, I got this: My
I would like to implement a ExpandableListView which should be expandable only after all
If i have a expandablelistview with custom layout (group.xml and child.xml), the are any
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
I created an ExpandableListView with the help of this tutorial: link . I understand
I use the code ExpandableListView expandListView = (ExpandableListView) findViewById(R.id.list); expandListView.setAdapter(adapter); Boolean flag = expandListView.setSelectedChild(1,
I want to create a two level ExpandableListView from a local database. The group
So if in void ChildClick(object o, ExpandableListView.ChildClickEventArgs e) o is the ExpandableListView that was

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.