自定義ScrollView解決onScrollChanged()方法不能調用的問題

/**
 * 自定義ScrollView解決onScrollChanged()方法不能調用的問題
 * 
 * @author LENOVO
 * 
 */
public class MyScrollView extends ScrollView {

	public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	public MyScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

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

	private ScrollViewListener scrollViewListener = null;

	public void setScrollViewListener(ScrollViewListener scrollViewListener) {
		this.scrollViewListener = scrollViewListener;
	}

	@Override
	protected void onScrollChanged(int x, int y, int oldx, int oldy) {
		super.onScrollChanged(x, y, oldx, oldy);
		if (scrollViewListener != null) {
			scrollViewListener.onScrollChanged(x, y, oldx, oldy);
		}
	}

	public interface ScrollViewListener {
		void onScrollChanged(int x, int y, int oldx,int oldy);
	}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章