我做了一个课程延伸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);
}
}
Run Code Online (Sandbox Code Playgroud)
我用它作为.
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);
Run Code Online (Sandbox Code Playgroud)
我也设置了成绩单模式TRANSCRIPT_MODE_ALWAYS_SCROLL
.但是,如果我点击多个项目,它不会滚动到最后,然后长度增加并且隐藏最终项目.我想要这样的东西:
您需要在列表视图中使用这些参数:
list.setTranscriptMode(ExpandableListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
Run Code Online (Sandbox Code Playgroud)
将列表的头部设置为底部
list.setStackFromBottom(true);
Run Code Online (Sandbox Code Playgroud)
您也可以在xml中设置
android:transcriptMode="alwaysScroll"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5982 次 |
最近记录: |