android listview判断是否滑动到顶部还是底部

 listView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem == 0) {
                    Toast.makeText(MyActivity.this, "滑到顶部",1).show();
                }
                if (visibleItemCount + firstVisibleItem == totalItemCount) {
                    Toast.makeText(MyActivity.this, "滑到底部",1).show();
                }
            }
        });

 

posted @ 2014-02-25 11:26  无忧之路  阅读(2627)  评论(0编辑  收藏  举报
无忧之路