我确实让拖放起作用了,而且TouchListView类工作得很好。然而,在我的例子中,由于我的适配器包含一个可以有多行的EditText,所以我有不同高度的行。因此,在我删除之后,我的所有行都会转换为tlv:normal_height,在我的例子中是74dip。这会导致很多行切掉EditTexts中的所有文本。我尝试重新初始化我的适配器(mylistview.setAdapter= myadapter),将ListView设置为GONE then VISIBLE和invalidateViews(),但似乎没有将ListView重置回我拖动之前的状态,除非离开活动并返回。这里可以做什么?-Thx
tlv:normal_height="74dip"
tlv:expanded_height="128dip"发布于 2012-01-11 19:36:23
毫无疑问,最初的AOSP代码是为统一的行高而设计的,整个expanded_height结构都是为了给用户提供可视化的空间,让他们想象在哪里会发生下落。
单凭这一点就足够了,还是需要做更多的工作,我不能说。
如果你想出一个解决方案,补丁是受欢迎的。否则,我可能会在某个时候看看这个,但不会太快。
发布于 2012-01-12 11:47:30
我编辑了名为getAdapter()的unExpandViews()方法,对于适配器中的每一项,将高度设置为0,然后将所有行设置回原始位置。我还绕过了方法的delete部分,因为它不适用于我。
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);
}
}
}https://stackoverflow.com/questions/8814373
复制相似问题