您的位置:首页 > 其它

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

2017-03-21 12:51 344 查看
首先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"
/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: