Android ListView addFooterView() issue

落爺英雄遲暮 提交于 2019-12-25 17:06:15

问题


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.

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

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).

Following is sample code

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.


回答1:


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.



来源:https://stackoverflow.com/questions/36739194/android-listview-addfooterview-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!