安卓:在列表视图水平荷载添加更多项目 [英] Android : Add Load more items in Horizontal listview

查看:262
本文介绍了安卓:在列表视图水平荷载添加更多项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用水平列表视图,并添加动态数据到这一点,但我想补充一个项目时,滚动中的列表视图达到最右边的项目
我怎样才能得到滚动达到最右边的位置?

I am using horizontal list view and adding dynamic data into this, but I want to add an item when the scroll reached to the right most item in the listview. How can I get that scroll reached to the right most position?

推荐答案

在为了做到这一点,你必须通过模拟适配器统治列表的大小。例如,如果列表被称为myList中,其大小为myList.size(),你将不得不做这样的事情:myList.add(mockelemnt)

In order to do that, you have to mock the size of the list ruled by your adapter. For example, if the list is called myList, its size is myList.size(), you will have to do something like: myList.add(mockelemnt).

现在你已经嘲笑的最后一个元素,你可能做的是处理它在你的适配器方法getView():

Now that you have mocked the last element, what you may do is to handle it on your adapter method getView():

@Override
   public View getView(int position, View convertView, ViewGroup parent){
        if (oistion < myList.size(){
           //work with conventional view
        }else if (postion == myList.size()){
           //work with addMore view
      }

}

希望它能帮助

这篇关于安卓:在列表视图水平荷载添加更多项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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