private boolean listViewStatus() { boolean flag = false; AdapterView<?> listView = null; for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); if (v instanceof AdapterView<?>) { listView = (AdapterView<?>) v; } } if (listView == null) { // return false; } int frist = listView.getFirstVisiblePosition(); int last = listView.getLastVisiblePosition(); View top = listView.getChildAt(0); View bottom = listView.getChildAt(listView.getChildCount() - 1); if (top != null && frist == 0 && top.getTop() == 0) { // 最顶端 moveStatus = STATUS_REFRESH_TOP; flag = true; } else if (bottom != null && last >= (listView.getCount() - 1) && bottom.getBottom() == listView.getHeight()) { // 最底端 moveStatus = STATUS_REFRESH_FOOTER; flag = true; } else { moveStatus = STATUS_REFRESH_NONE; flag = false; } return flag; }
private static boolean canAdapterViewScroll(AdapterView lv) { /* Force it to layout it's children */ if (lv.getLastVisiblePosition() == -1) return false; /* We can scroll if the first or last item is not visible */ boolean firstItemVisible = lv.getFirstVisiblePosition() == 0; boolean lastItemVisible = lv.getLastVisiblePosition() == lv.getCount() - 1; if (firstItemVisible && lastItemVisible && lv.getChildCount() > 0) { /* Or the first item's top is above or own top */ if (lv.getChildAt(0).getTop() < lv.getPaddingTop()) return true; /* or the last item's bottom is beyond our own bottom */ return lv.getChildAt(lv.getChildCount() - 1).getBottom() > lv.getHeight() - lv.getPaddingBottom(); } return true; }