如何找出是否有的ListView滚动到最上面的位置? [英] How to find out if ListView has scrolled to top Most position?

查看:114
本文介绍了如何找出是否有的ListView滚动到最上面的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView,第一它向下滚动,现在当我们向上滚动,它达到最顶端点。我想检测。就是有什么办法?我开发应用程序的API级别8.Pls帮助..

I have a ListView, first its scrolled down, now when we scroll up,it reach top most point. I want to detect that .Is there any way?I am developing application with api level 8.Pls help..

推荐答案

修改

见下面的意见,为什么,特别是在不同的API版本(尤其是后来者),这不是一个简单的方法,如果你列表的顶部(填充等)。但是,它给你一个开端低于API 14设备的解决方案:

See comments below as to why, especially on different API versions (esp later ones), this isn't a foolproof way to see if you're list is at the top (padding etc). However, it does give you a start for a solution on devices below API 14:

private boolean listIsAtTop()   {   
    if(listView.getChildCount() == 0) return true;
    return listView.getChildAt(0).getTop() == 0;
}

据我实施年前 - 这工作完全在当时

As far as my implementation years ago - this worked perfectly at the time.

这篇关于如何找出是否有的ListView滚动到最上面的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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