Android ListView addFooterView()问题 [英] Android ListView addFooterView() issue

查看:93
本文介绍了Android ListView addFooterView()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从服务响应中填充的ListView.调用服务时,我通过显示进度条视图来显示进度条,方法是通过扩展进度条视图并在列表视图填充后将其隐藏.

I have a ListView which is getting populated from service response. When service is called i am showing a progressbar by adding footerview by inflating progressbar view and hiding it once listview is populated.

注意:我在设置适配器之前添加了footerview.然后在每个服务呼叫中添加footerview.

Note: I am adding footerview before setting adapter. Then i am adding footerview at each service call.

问题:当服务返回非空响应时,一切工作正常(在填充listview后显示和隐藏footerview) 当服务响应为空时,即下一个方法中的listview为空,则对addFooterView()的调用不起作用(不显示footerview).

problem: when service returns non empty response everything is working fine(footerview is shown and hided after listview is populated) when service response is empty i.e. listview is empty in next method calls to addFooterView() not working(not showing footerview).

以下为示例代码

addFooterView(loadingView, null, false);
m_List.addAll(listItems);
m_adapter.notifyDataSetChanged();
removeFooterView(loadingView);

注意:如果每次列表大小都大于零,我都不会遇到问题.

Note: If each time list size is greater than zero i am not facing problem.

推荐答案

如果您的arraylist包含绑定到适配器的数据,请添加页脚视图,并在添加之前检查listView.getFooterViewCount.

add footer view if your arraylist has data that is binding to your adapter and also check listView.getFooterViewCount before adding if it is already has.

这篇关于Android ListView addFooterView()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆