我已经实现了一个侦听器类来检测链接
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(); }
}