我的问题可能与此相关的一个:touchlistview自定义页脚阻止列表大小更新
Add footer to Android TouchListView
在Commonware的touchlistview https://github.com/commonsguy/cwac-touchlist/blob/master/demo/src/com/commonsware/cwac/tlv/demo/TouchListViewDemo.java
的演示项目一个简单的TextView添加为页脚该工程确定。当我添加自己的时候,它会在删除项目时崩溃。最初有4个项目,在移除4个项目后,页脚停留在5号位置。
这是我如何添加页脚:
View footerView = ((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_cloud, null, false);
这是XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="64dip"
android:gravity="center_vertical"
>
<ImageView android:id="@+id/add_icon"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_add"
/>
<ImageView android:id="@+id/cloudBG"
android:layout_centerInParent="true"
android:layout_width="230dp"
android:layout_height="60dp"
android:background="@drawable/cl"
/>
</RelativeLayout>
增加调试到onRemove:
Log.d("tlv","count b4 remove "+adapter.getCount()+" aray: "+array.size());
adapter.remove(adapter.getItem(which));
//adapter.notifyDataSetChanged();
Log.d("tlv","count after remove "+adapter.getCount()+" aray: "+array.size());
显示适配器和数组大小正在更新
我在touchlistview.java中更改了一些代码,以便在将项目拖动到最低项目下时修复崩溃:
Log.d(“tlv”,“drag from”+ mFirstDragPos +“to”+ mDragPos +“cnt”+ getCount将());
if(mDragPos < getCount()-this.getFooterViewsCount()){// Nino van Hooff: fix out of bounds
mDropListener.drop(mFirstDragPos, mDragPos);
}else{
mDropListener.drop(mFirstDragPos, mDragPos-1);
}
}
unExpandViews(false);
利用getCount函数总是返回相同数量(项目+ 1页脚的量),项目被删除
谁知道我的自定义页脚的区别是什么,即使后?
你可以发布一个链接到一个完整的示例应用程序,演示问题?您可能会在TouchListView中遇到一些我可能能够纠正的限制。 – CommonsWare
感谢您的快速回复! [链接到完整的eclipse项目](http://hooffzaken.nl/junk/baby_names。zip) –
你的项目很奇怪。就好像你把你的代码放在'TouchListView'库项目中,这当然不是设置某种东西的预期方式。我无法通过Eclipse或通过命令行构建它。我会尽我所能在这个问题上做一些尝试。 – CommonsWare