android – onScrollChanged在scrollView中多次触发滚动结束

前端之家收集整理的这篇文章主要介绍了android – onScrollChanged在scrollView中多次触发滚动结束前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经实现了一个侦听器类来检测链接 https://gist.github.com/marteinn/9427072的滚动视图结束
public class ResponsiveScrollView extends ScrollView {

private OnBottomReachedListener listener;

public ResponsiveScrollView(Context context) {
    super(context);
}

@Override
protected void onScrollChanged(int l,int t,int oldl,int oldt) {
    View view = getChildAt(getChildCount()-1);
    int diff = view.getBottom()-(getHeight()+getScrollY());
    if (diff == 0 && listener!= null) {
        listener.onBottomReached(this);
    }
    super.onScrollChanged(l,t,oldl,oldt);
}

public OnBottomReachedListener getBottomChangedListener() {
        return listener;
}

public void setBottomReachesListener(OnBottomReachedListener onBottomReachedListener) {
    this.listener = onBottomReachedListener;
}

public interface OnBottomReachedListener {
    public void onBottomReached(View view);
   }
}

监听器设置为scrollView:

scrollView.setBottomReachesListener(new GenericScrollListerner(this));

我的GenericScrollListerner类:

public class GenericScrollListerner implements ResponsiveScrollView.OnBottomReachedListener {
private Context mContext;

public GenericScrollListerner(Context context) {
    this.mContext = context;
}

@Override
public void onBottomReached(View view) {
    Log.d("ScrollView","Scroll end");
    String tag = (String) view.getTag();
    Toast.makeText(mContext,"Scroll end with tag" +tag,Toast.LENGTH_SHORT).show();
}

}

我的问题是onBottomReached在大多数情况下都会触发两次.如何处理这个问题???

解决方法


504 Gateway Time-out

504 Gateway Time-out


Nginx/1.12.2
原文链接:https://www.f2er.com/android/308959.html

猜你在找的Android相关文章