本文介绍了安卓:什么ListView.setScrollIndicators(上,下)呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想咨询文档,却发现setScrollIndicators空在那里。它做什么?

I tried to consult documentation, but found setScrollIndicators empty there. What it does?

推荐答案

我试图寻找,但无法找到任何文件。
不过,虽然看着AbsListView来源,我发现以下

I tried to search but couldn't find documentation either.But while looking at source of AbsListView, I found following

 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是

Here mListPadding is

   Rect mListPadding = new Rect();

这可能有助于理解的概念更好。我没有试过,但还没有从我的理解,如果最后一个元素或最后一个元素的列表视图或底部的第一个元素的顶部是不可见的,如果列表可以滚动(向上或向下),那么各自的观点得到由可见调用updateScrollIndicators()方法

This might help in understanding concept better. I haven't tried this yet but from my understanding, if top of first element of the listview or bottom of the last element or last element is not visible and if list can be scrollable (to up or down) then respective view gets visible by calling updateScrollIndicators() method

希望这将是对您有用。

这篇关于安卓:什么ListView.setScrollIndicators(上,下)呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 02:57