Java android.widget.AbsListView.OnScrollListener 代码实例

以下是展示如何使用android.widget.AbsListView.OnScrollListener的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀示例。

实例 1


@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            imageLoader.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                imageLoader.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                imageLoader.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}
 

实例 2


public final void onScrollStateChanged(final AbsListView view, final int state) {
	/**
	 * Check that the scrolling has stopped, and that the last item is
	 * visible.
	 */
	if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) {
		mOnLastItemVisibleListener.onLastItemVisible();
	}

	if (null != mOnScrollListener) {
		mOnScrollListener.onScrollStateChanged(view, state);
	}
}
 

实例 3


public void postSetSelection(final int position) {
  clearFocus();
  post(new Runnable() {

    @Override
    public void run() {
      setSelection(position);
    }
  });
  onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}
 

实例 4


public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
    case OnScrollListener.SCROLL_STATE_IDLE:
        mBusy = false;
        
        int first = view.getFirstVisiblePosition();
        int count = view.getChildCount();
        for (int i=0; i<count; i++) {
            TextView t = (TextView)view.getChildAt(i);
            if (t.getTag() != null) {
                t.setText(mStrings[first + i]);
                t.setTag(null);
            }
        }
        
        mStatus.setText("Idle");
        break;
    case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
        mBusy = true;
        mStatus.setText("Touch scroll");
        break;
    case OnScrollListener.SCROLL_STATE_FLING:
        mBusy = true;
        mStatus.setText("Fling");
        break;
    }
}
 

实例 5


public void postSetSelection(final int position) {
    clearFocus();
    post(new Runnable() {

        @Override
        public void run() {
            setSelection(position);
        }
    });
    onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE);
}

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐