3
我試着諮詢documentation,但發現setScrollIndicators在那裏空了。它能做什麼?Android:ListView.setScrollIndicators(上,下)是做什麼的?
我試着諮詢documentation,但發現setScrollIndicators在那裏空了。它能做什麼?Android:ListView.setScrollIndicators(上,下)是做什麼的?
我試圖搜索,但無法找到文檔。 不過,雖然看着AbsListView的來源,我發現以下
View mScrollUp;
View mScrollDown;
public void setScrollIndicators(View up, View down) {
mScrollUp = up;
mScrollDown = down;
}
void updateScrollIndicators() {
if (mScrollUp != null) {
boolean canScrollUp;
// 0th element is not visible
canScrollUp = mFirstPosition > 0;
// ... Or top of 0th element is not visible
if (!canScrollUp) {
if (getChildCount() > 0) {
View child = getChildAt(0);
canScrollUp = child.getTop() < mListPadding.top;
}
}
mScrollUp.setVisibility(canScrollUp ? View.VISIBLE : View.INVISIBLE);
}
if (mScrollDown != null) {
boolean canScrollDown;
int count = getChildCount();
// Last item is not visible
canScrollDown = (mFirstPosition + count) < mItemCount;
// ... Or bottom of the last element is not visible
if (!canScrollDown && count > 0) {
View child = getChildAt(count - 1);
canScrollDown = child.getBottom() > mBottom - mListPadding.bottom;
}
mScrollDown.setVisibility(canScrollDown ? View.VISIBLE : View.INVISIBLE);
}
}
這裏mListPadding是
Rect mListPadding = new Rect();
這可能在理解概念更好的幫助。我還沒有嘗試過,但從我的理解,如果列表視圖的第一個元素的頂部或最後一個元素或最後一個元素的底部不可見,並且如果列表可以滾動(向上或向下),則相應的視圖可以通過調用updateScrollIndicators()方法
希望這將是對您有用
http://docs.go-mono.com/index.aspx?link=M%3AAndroid.Widget.AbsListView.SetScrollIndicators(Android.Views .View%2CAndroid.Views.View)還沒有文檔。 – Govil