android listview判斷是否滑動到頂部還是底部
阿新 • • 發佈:2019-06-24
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(); }