本文整理汇总了Java中android.widget.AbsListView.OnScrollListener方法的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.OnScrollListener方法的具体用法?Java AbsListView.OnScrollListener怎么用?Java AbsListView.OnScrollListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.OnScrollListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setAbsListViewOnScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
private void setAbsListViewOnScrollListener() {
if (mAbsListView != null) {
try {
// 通过反射获取开发者自定义的滚动监听器,并将其替换成自己的滚动监听器,触发滚动时也要通知开发者自定义的滚动监听器(非侵入式,不让开发者继承特定的控件)
// mAbsListView.getClass().getDeclaredField("mOnScrollListener")获取不到mOnScrollListener,必须通过AbsListView.class.getDeclaredField("mOnScrollListener")获取
Field field = AbsListView.class.getDeclaredField("mOnScrollListener");
field.setAccessible(true);
// 开发者自定义的滚动监听器
final AbsListView.OnScrollListener onScrollListener = (AbsListView.OnScrollListener) field.get(mAbsListView);
mAbsListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
if ((scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_FLING) && shouldHandleAbsListViewLoadingMore(mAbsListView)) {
beginLoadingMore();
}
if (onScrollListener != null) {
onScrollListener.onScrollStateChanged(absListView, scrollState);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (onScrollListener != null) {
onScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例3: RecyclerToListViewScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
public RecyclerToListViewScrollListener(AbsListView.OnScrollListener scrollListener) {
this.scrollListener = scrollListener;
}
示例4: setOnScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener onScrollListener) {
this.onScrollListener = onScrollListener;
}
示例5: setOnScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener onScrollListener) {
mOnScrollListener = onScrollListener;
}
示例6: makeScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* Return ScrollListener for ListView
*
* @return OnScrollListener
*/
public AbsListView.OnScrollListener makeScrollListener() {
return new AbsListView.OnScrollListener() {
private boolean isFirstItem = false;
private boolean isLastItem = false;
@Override
public void onScrollStateChanged(AbsListView absListView, int scrollState) {
setEnabled(scrollState != AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
if (swipeClosesAllItemsWhenListMoves && scrollState == SCROLL_STATE_TOUCH_SCROLL) {
closeOpenedItems();
}
if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
listViewMoving = true;
setEnabled(false);
}
if (scrollState != AbsListView.OnScrollListener.SCROLL_STATE_FLING && scrollState != SCROLL_STATE_TOUCH_SCROLL) {
listViewMoving = false;
downPosition = ListView.INVALID_POSITION;
swipeListView.resetScrolling();
new Handler().postDelayed(new Runnable() {
public void run() {
setEnabled(true);
}
}, 500);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (isFirstItem) {
boolean onSecondItemList = firstVisibleItem == 1;
if (onSecondItemList) {
isFirstItem = false;
}
} else {
boolean onFirstItemList = firstVisibleItem == 0;
if (onFirstItemList) {
isFirstItem = true;
swipeListView.onFirstListItem();
}
}
if (isLastItem) {
boolean onBeforeLastItemList = firstVisibleItem + visibleItemCount == totalItemCount - 1;
if (onBeforeLastItemList) {
isLastItem = false;
}
} else {
boolean onLastItemList = firstVisibleItem + visibleItemCount >= totalItemCount;
if (onLastItemList) {
isLastItem = true;
swipeListView.onLastListItem();
}
}
}
};
}
示例7: RecyclerToListViewScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
public RecyclerToListViewScrollListener(AbsListView.OnScrollListener scrollListener) {
this.scrollListener = scrollListener;
}
示例8: setScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
/**
* 设置listview的滚动监听
*/
public void setScrollListener(AbsListView.OnScrollListener mScrollListener) {
this.mScrollListener = mScrollListener;
}
示例9: setOriginalListener
import android.widget.AbsListView; //导入方法依赖的package包/类
void setOriginalListener(AbsListView.OnScrollListener originalListener) {
this.originalListener = originalListener;
}
示例10: setOnScrollListener
import android.widget.AbsListView; //导入方法依赖的package包/类
public void setOnScrollListener(AbsListView.OnScrollListener l) {
mExternalOnScrollListener = l;
}