我编辑了unExpandViews()方法 - 称为getAdapter(),并且对于我的适配器中的每个项目,将高度设置为0,然后将所有行设置回原始。我也绕过了删除部分的方法,因为它不适用于我。
private void unExpandViews(boolean deletion) {
int height_saved = 0;
CheckBoxifiedTextListAdapter cbla = (CheckBoxifiedTextListAdapter)getAdapter();
for (int i = 0;i < cbla.getCount(); i++)
{
//View v = getChildAt(i);
View v = cbla.getView(i, null, null);
//if (v == null)
//{
/*
if (deletion)
{
// HACK force update of mItemCount
int position = getFirstVisiblePosition();
int y = getChildAt(0).getTop();
setAdapter(getAdapter());
setSelectionFromTop(position, y);
// end hack
}
layoutChildren(); // force children to be recreated where needed
v = getChildAt(i);
if (v == null)
{
break;
}
height_saved = v.getHeight();
*/
//}
//else
//height_saved = v.getHeight();
if (isDraggableRow(v))
{
ViewGroup.LayoutParams params = v.getLayoutParams();
params.height = 0;
v.setLayoutParams(params);
v.setVisibility(View.VISIBLE);
}
}
}
我明白了,谢谢。我会看看是否可以编辑TouchListView类并查看是否可以根据ListView项目的高度动态设置行高。我假设我可以从TouchListView类访问ListView的适配器 - 那么你能指点我在代码中的正确位置吗? – Mike6679 2012-01-11 17:19:34
@Mike:使用'getAdapter()'获取适配器。 – CommonsWare 2012-01-11 17:21:25