大家.当用户到达列表底部时,我想显示"Loading ..."这样的页脚.现在我只能确定我们何时在最后一个元素上.然后麻烦来了.我们需要在设置适配器之前设置页脚,我们需要在之后隐藏它.有人有解决方案吗?可能已经讨论过这个问题,但我还没有找到答案.
您可以在设置适配器之前添加页脚
listView.addFooterView(yourFooterView, null, true);
Run Code Online (Sandbox Code Playgroud)
*请注意,参数应适合您的目标。
然后你的活动可以实现OnScrollListener,并且在该方法上onScroll你可以得到最后一个项目,如下所示:
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount){
int lastItem = firstVisibleItem + visibleItemCount;
if(lastItem == totalItemCoun){
// fill your next set of items
}
}
Run Code Online (Sandbox Code Playgroud)
新组填满后,页脚将再次转到底部,因此您不必隐藏它。但是,如果您想删除它,您可以使用
lv.removeFooterView(yourFooterView);
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助
| 归档时间: |
|
| 查看次数: |
4166 次 |
| 最近记录: |