Android的 - 如何才能知道什么时候GridView控件已经触底? [英] Android - how can i know when gridview has reached the bottom?

查看:159
本文介绍了Android的 - 如何才能知道什么时候GridView控件已经触底?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个应用程序,加载图像从JSON并将其显示为网格视图。 问题是,有数百张照片,我想每一次装载20, 我想从服务器上下载更多的图片,当滚动到达底部。 所以,我怎么能告诉当电网视图到达底部? 我在网上搜索,并无法弄清楚这个...

I'm building an app that loads images from JSON and displays them as grid view. the problem is that there are hundreds of images and i want to load 20 each time, I want to download more pictures from the server when the scroll reaches the bottom. so, how can i tell when the grid view reaches the bottom? I've searched the web and couldn't figure this one...

任何人有想法?

我添加一个应用程序,做一些非常相似,我想要的照片。 谢谢。

I'm adding a photo of an app that does something very similar to what i want. thanks.

推荐答案

您可以使用<一个href="http://developer.android.com/reference/android/widget/AbsListView.html#setOnScrollListener%28android.widget.AbsListView.OnScrollListener%29">setOnScrollListener为你的GridView。

You can use setOnScrollListener to your GridView.

下面是code例如:

gridView.setOnScrollListener(new OnScrollListener(){
    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
       {
        if(firstVisibleItem + visibleItemCount >= totalItemCount){
            // End has been reached
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState){

    }
});

这篇关于Android的 - 如何才能知道什么时候GridView控件已经触底?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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