Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to scroll an expandable list view till its end?

Tags:

android

scroll

I made a class extending ExpandableListView. Following is the code :

class CustomExpandableListView extends ExpandableListView {
        public CustomExpandableListView(Context context) {
            super(context);
        }

        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            /*
             * Adjust height
             */
            heightMeasureSpec = MeasureSpec.makeMeasureSpec(
                    700, MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        }
    } 

And I used it as.

ExpandableListView list = new CustomExpandableListView(KaasMain.this);
Adapter adapter = new Adapter(KaasMain.this, objectsLvl1);
                list.setAdapter(adapter);

                parent.addView(list);

                // list.setGroupIndicator();
                list.setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

                list.setIndicatorBounds(0, 0);
                list.setChildIndicatorBounds(0, 0);

I also set its transcript mode TRANSCRIPT_MODE_ALWAYS_SCROLL. But its not scrolling till the end if i clicking on multiple items then the length increases and its hiding end items. I want something like this:

enter image description here

like image 923
Baby Be'el Avatar asked May 04 '13 06:05

Baby Be'el


People also ask

How do you use expandable list view?

Android ExpandableListView is a view that shows items in a vertically scrolling two-level list. It differs from a ListView by allowing two levels which are groups that can be easily expanded and collapsed by touching to view and their respective children items.

What is ExpandableListView in Android?

android.widget.ExpandableListView. A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view.


1 Answers

You need to use these parameters in your list view:

list.setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

Set the head of the list to it bottom

list.setStackFromBottom(true);

You can also set in your xml

android:transcriptMode="alwaysScroll"
like image 157
Linga Avatar answered Oct 14 '22 09:10

Linga