本文整理汇总了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);
}
}
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例5: attach
import android.widget.AbsListView; //导入方法依赖的package包/类
void attach(AbsListView listView) {
listView.setOnScrollListener(this);
}
示例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;
}
});
}
示例7: listenTo
import android.widget.AbsListView; //导入方法依赖的package包/类
public void listenTo(AbsListView listView) {
if (null != listView) {
listView.setOnScrollListener(new DirectionScrollListener(this));
}
}
示例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);
}