Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Context;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.ScrollView;
- class LockableScrollView extends ScrollView {
- public LockableScrollView(Context context) {
- super(context);
- // TODO Auto-generated constructor stub
- }
- // true if we can scroll (not locked)
- // false if we cannot scroll (locked)
- private boolean mScrollable = true;
- public void setIsScrollable(boolean scrollable) {
- mScrollable = scrollable;
- }
- public boolean getIsScrollable(){
- return mScrollable;
- }
- @Override
- public boolean onTouch(View v, MotionEvent ev) {
- switch (ev.getAction()) {
- case MotionEvent.ACTION_DOWN:
- // if we can scroll pass the event to the superclass
- if (mScrollable) super.onTouch(v, ev);
- // only continue to handle the touch event if scrolling enabled
- return mScrollable;
- default:
- return super.onTouchEvent(v, ev);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement