查出的ListView滚动至底部? [英] Find out if ListView is scrolled to the bottom?

查看:97
本文介绍了查出的ListView滚动至底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以看看我的ListView滚动至底部?我的意思是,最后一个项目是完全可见。

Can I find out if my ListView is scrolled to the bottom? By that I mean that the last item is fully visible.

推荐答案

编辑

由于我一直在调查在我的应用程序之一这个特殊的问题,我可以写这个问题未来的读者扩展的答案。

Since I have been investigating in this particular subject in one of my applications, I can write an extended answer for future readers of this question.

实施的 OnScrollListener ,设置的ListView onScrollListener 键,那么你应该能够正确地处理事情。

Implement an OnScrollListener, set your ListView's onScrollListener and then you should be able to handle things correctly.

例如:

private int preLast;
// Initialization stuff.
yourListView.setOnScrollListener(this);

// ... ... ...

@Override
public void onScroll(AbsListView lw, final int firstVisibleItem,
                 final int visibleItemCount, final int totalItemCount) {

    switch(lw.getId()) {
        case android.R.id.list:     

            // Make your calculation stuff here. You have all your
            // needed info from the parameters of this function.

            // Sample calculation to determine if the last 
            // item is fully visible.
             final int lastItem = firstVisibleItem + visibleItemCount;
           if(lastItem == totalItemCount) {
              if(preLast!=lastItem){ //to avoid multiple calls for last item
                Log.d("Last", "Last");
                preLast = lastItem;
              }
           }
    }
}

这篇关于查出的ListView滚动至底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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