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"); } });
[開發] setOnScrollListener() 簡介
最近被 ListView搞到快死掉,所以就順便簡單介紹一下 ListView的Scroll
提醒
本站內容即日起將轉到另一站上轉跳~