android - 如何将可扩展 ListView 滚动到最后?

标签 android scroll

我制作了一个扩展 ExpandableListView 的类。以下是代码:

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);

        }
    } 

我用它作为。

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);

我还设置了它的转录模式 TRANSCRIPT_MODE_ALWAYS_SCROLL。但是,如果我单击多个项目,则它不会滚动到最后,然后长度会增加并隐藏最终项目。 我想要这样的东西:

enter image description here

最佳答案

您需要在 ListView 中使用这些参数:

list.setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);

将列表的头部设置为底部

list.setStackFromBottom(true);

你也可以在你的xml中设置

android:transcriptMode="alwaysScroll"

关于android - 如何将可扩展 ListView 滚动到最后?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16371309/

相关文章:

java - 如何从不同的 XML 更改 ImageView 源?

java - 通过 Fragment 父类(super class)或扩展 Fragment 类引用 fragment 有什么区别?

iOS 表格 View ——我不知道这是否可行

python - 将 QTableWidget 滚动到特定列

android - 如何在 google maps API V2 Android 中将图像添加到标记的 InfoWindow 中?

android - 修复了移动版网站中的页眉和页脚

Android:打开和关闭 SQLite 数据库

android - 如何在android中选择微调器时停止将屏幕滚动到顶部

javascript - iPhone 上滚动事件内的 SetInterval - 为什么此代码不起作用?

ios - 可以向上滚动具有几行的 Swift TableView