我制作了一个扩展 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
。但是,如果我单击多个项目,则它不会滚动到最后,然后长度会增加并隐藏最终项目。
我想要这样的东西:
最佳答案
您需要在 ListView 中使用这些参数:
list.setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
将列表的头部设置为底部
list.setStackFromBottom(true);
你也可以在你的xml中设置
android:transcriptMode="alwaysScroll"
关于android - 如何将可扩展 ListView 滚动到最后?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16371309/