pulltorefreshlistview notifydatasetchanged数据无效与getView没有执行

来源:互联网 发布:阿里云的钱怎么提现 编辑:程序博客网 时间:2024/06/11 01:40

首先notifydatasetchanged 无效问题,需要在getCount,getView 中打印日志或者使用断点看一下是不是执行了,对于count或者数据源没有改变是不执行getView的。

对于listview布局异常也不会执行getView,例如listview不可见或者高度设置为0.对于pulltorefreshlistview 我在布局上使用了wrap_content,那么导致布局高度展示为0;那么也是不执行getView。所以总结:notifydatasetchanged数据刷新无效,大致分为数据绑定或者指向上有问题和视图布局有问题。

<com.handmark.pulltorefresh.library.PullToRefreshListView    android:layout_height="wrap_content"    android:layout_width="match_parent"    android:id="@+id/comment_list"    android:divider="@null"    android:dividerHeight = "0dp"    />
修改为:

<com.handmark.pulltorefresh.library.PullToRefreshListView    android:layout_height="match_parent"    android:layout_width="match_parent"    android:id="@+id/comment_list"    android:divider="@null"    android:dividerHeight = "0dp"    />

0 0