当前位置: 首页>>代码示例>>Java>>正文


Java AbsListView.setOnScrollListener方法代码示例

本文整理汇总了Java中android.widget.AbsListView.setOnScrollListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.setOnScrollListener方法的具体用法?Java AbsListView.setOnScrollListener怎么用?Java AbsListView.setOnScrollListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AbsListView的用法示例。


在下文中一共展示了AbsListView.setOnScrollListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAbsListViewOnScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
private void setAbsListViewOnScrollListener(AbsListView absListView) {
    if (absListView != null) {
        try {
            // 通过反射获取滚动监听器,设置自己的滚动监听器后通知之前已有的监听
            Field field = AbsListView.class.getDeclaredField("mOnScrollListener");
            field.setAccessible(true);
            // 开发者自定义的滚动监听器
            AbsListView.OnScrollListener onScrollListener = (AbsListView.OnScrollListener) field.get(absListView);
            if (absListViewScrollListener == null) {
                absListViewScrollListener = new AbsListViewScrollListener();
            }
            if (onScrollListener != absListViewScrollListener){
                absListViewScrollListener.setOriginalListener(onScrollListener);
                absListView.setOnScrollListener(absListViewScrollListener);
            }
        } catch (Exception e) {
            Log.e(TAG, "反射获取AbsListView#OnScrollListener异常", e);
        }
    }
}
 
开发者ID:excitedhaha,项目名称:RefreshLoadLayout,代码行数:21,代码来源:RefreshLoadLayout.java

示例2: onFinishInflate

import android.widget.AbsListView; //导入方法依赖的package包/类
@Override
public void onFinishInflate() {
    super.onFinishInflate();

    if (getChildCount() != 3) {
        throw new IllegalStateException(BGAStickyNavLayout.class.getSimpleName() + "必须有且只有三个子控件");
    }

    mHeaderView = getChildAt(0);
    mNavView = getChildAt(1);
    mContentView = getChildAt(2);

    if (mContentView instanceof AbsListView) {
        mDirectAbsListView = (AbsListView) mContentView;
        mDirectAbsListView.setOnScrollListener(mLvOnScrollListener);
    } else if (mContentView instanceof RecyclerView) {
        mDirectRecyclerView = (RecyclerView) mContentView;
        mDirectRecyclerView.addOnScrollListener(mRvOnScrollListener);
    } else if (mContentView instanceof ScrollView) {
        mDirectScrollView = (ScrollView) mContentView;
    } else if (mContentView instanceof WebView) {
        mDirectWebView = (WebView) mContentView;
    } else if (mContentView instanceof ViewPager) {
        mDirectViewPager = (ViewPager) mContentView;
        mDirectViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                regetNestedContentView();
            }
        });
    } else {
        mDirectNormalView = mContentView;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:BGAStickyNavLayout.java

示例3: attachToListView

import android.widget.AbsListView; //导入方法依赖的package包/类
public void attachToListView(@NonNull AbsListView listView, ScrollDirectionListener listener) {
    AbsListViewScrollDetectorImpl scrollDetector = new AbsListViewScrollDetectorImpl();
    scrollDetector.setListener(listener);
    scrollDetector.setListView(listView);
    scrollDetector.setScrollThreshold(mScrollThreshold);
    listView.setOnScrollListener(scrollDetector);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:8,代码来源:FloatingActionsMenu.java

示例4: setScrollListener

import android.widget.AbsListView; //导入方法依赖的package包/类
public void setScrollListener() {
    if (child instanceof AbsListView) {
        AbsListView absListView = (AbsListView) child;
        absListView.setOnScrollListener(this);
    } else if (child instanceof ScrollView) {
        setScrollViewScrollListener();

    } else if (child instanceof RecyclerView) {
        setRecyclerViewScrollListener();
    }
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:12,代码来源:XRefreshContentView.java

示例5: attach

import android.widget.AbsListView; //导入方法依赖的package包/类
void attach(AbsListView listView) {
    listView.setOnScrollListener(this);
}
 
开发者ID:Brave-wan,项目名称:SmartRefresh,代码行数:4,代码来源:RefreshContentWrapper.java

示例6: initList

import android.widget.AbsListView; //导入方法依赖的package包/类
/**
 * According the view mode, get the common object for the adapter.
 */
private void initList(final AbsListView list){
    list.setOnItemClickListener(this);
    list.setOnItemLongClickListener(this);
    // register for context menu.
    list.setOnCreateContextMenuListener(this);
    list.setOnScrollListener(this);
    list.setOnTouchListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    // Setup key listener to open extender with right key or L1 or R1 or "i"
    list.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // All is done on action down because it also moves the focus, hence we can't wait for action up

             
             /*
              * Work around to handle issues on focus for android 4.1
              * 
              * Sometimes it is impossible to down with the pad.
              * what we know :
              * before going to the onkey method, list should have scrolled (except when and issue occured)
              * so, if we are going down, the last visible item has to be focused item +1 (focus is done after the function, when  return false)
              * if last visible item == selected item even if this isn't the last item of the list, then the list won't scroll anymore.
              * So we scroll it manually.
              * 
              */
            if (event.getAction() == KeyEvent.ACTION_DOWN && mArchosGridView instanceof ListView) {
                if (keyCode == KeyEvent.KEYCODE_DPAD_UP && mArchosGridView.getFirstVisiblePosition() == mArchosGridView.getSelectedItemPosition() && mArchosGridView.getSelectedItemPosition() > 0) {

                    mArchosGridView.setSelection(mArchosGridView.getSelectedItemPosition() - 1);
                    return true;


                }
                if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && mArchosGridView.getLastVisiblePosition() == mArchosGridView.getSelectedItemPosition()
                        && mArchosGridView.getSelectedItemPosition() < mArchosGridView.getCount()) {
                    View v2 = mArchosGridView.getChildAt(mArchosGridView.getSelectedItemPosition() - mArchosGridView.getFirstVisiblePosition());
                    int scrollTo = (v2 == null) ? 0 : v2.getTop();
                    //we want the selected item to be at the end of the list
                    if (mArchosGridView instanceof ListView)
                        ((ListView) mArchosGridView).setSelectionFromTop(mArchosGridView.getSelectedItemPosition() + 1,
                                scrollTo);
                    return true;


                }

            }
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;
            if ((keyCode == KeyEvent.KEYCODE_BUTTON_L1) || (keyCode == KeyEvent.KEYCODE_BUTTON_R1) ||   // Nice for LUDO (even if an hidden feature)
                    (keyCode == KeyEvent.KEYCODE_I) ||                                                // Nice for any keyboard, LUDO included
                    ((keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) && (list instanceof GridView && (((GridView) list).getNumColumns() < 2) || list instanceof ListView)))// Right arrow is only used in list mode, can't be in grid mode
            {
                View selectedView = list.getSelectedView();
                if (selectedView != null) {
                    // Check that there is a visible "expander" in the selected list item
                    View expandView = selectedView.findViewById(R.id.expanded);
                    if ((expandView != null) && (expandView.getVisibility() == View.VISIBLE)) {
                        if (getFileType(list.getSelectedItemPosition()) == FileType.SmbDir)
                            return false;
                        expandView.requestFocus(); //test
                        displayInfo(list.getSelectedItemPosition());
                        return true;
                    }
                }
            }
            return false;
        }
    });

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:76,代码来源:Browser.java

示例7: listenTo

import android.widget.AbsListView; //导入方法依赖的package包/类
public void listenTo(AbsListView listView) {
    if (null != listView) {
        listView.setOnScrollListener(new DirectionScrollListener(this));
    }
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:6,代码来源:FloatingActionButton.java

示例8: setAssociatedListView

import android.widget.AbsListView; //导入方法依赖的package包/类
/**
 * Set associated list view, then this layout will only be able to drag down when the list
 * view is scrolled to top.
 *
 * @param listView
 */
public void setAssociatedListView(AbsListView listView) {
    listView.setOnScrollListener(associatedListViewListener);
    updateListViewScrollState(listView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ScrollLayout.java


注:本文中的android.widget.AbsListView.setOnScrollListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。