listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
updateBackTopButtonState();
}
});
private void updateBackTopButtonState() {
if (adapter != null && adapter.getCount() > 0 && listView.getFirstVisiblePosition() >= 3) {
setBackTopButtonState(true);
} else {
setBackTopButtonState(false);
}
}
getlast()方法也可以做返回顶部
时间: 2024-11-01 08:06:22