2015年8月10日 星期一

setOnScrollListener() 簡介

http://123android.blogspot.tw/2013/01/setonscrolllistener.html

list.setOnScrollListener(new OnScrollListener(){
    @Override
    public void onScrollStateChanged(AbsListView absListView, int scrollState) {
        switch(scrollState) { 
            case SCROLL_STATE_FLING: 
                Log.i("Scroll State","滾動中...");
                break; 
            case SCROLL_STATE_IDLE: 
                Log.i("Scroll State","滾動停止...");
                break; 
            case SCROLL_STATE_TOUCH_SCROLL: 
                Log.i("Scroll State","手指滾動...");
                break; 
        }
    }

    @Override
    public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
              Log.i("OnScroll","Scroll");
        Log.i("OnScroll","firstVisibleItem:" + firstVisibleItem + " 最上面Item的編號");
        Log.i("OnScroll","visibleItemCount:" + visibleItemCount + " 你目前可以看到多少個 item");
        Log.i("OnScroll","totalItemCount:" + totalItemCount + " 你總共有多少個 Item");   
    }
});

listView_webview.setOnScrollListener(new OnScrollListener() {

@Override

public void onScrollStateChanged(AbsListView view, int scrollState) {

switch (scrollState) {

// 当不滚动时

case OnScrollListener.SCROLL_STATE_IDLE:

// 判断滚动到底部

if (view.getLastVisiblePosition() == (view.getCount() - 1)) {

Log.i("--webview_over", "yes");



}

break;

}

}



@Override

public void onScroll(AbsListView view, int firstVisibleItem,

int visibleItemCount, int totalItemCount) {



}

});