본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[android] how to disable gridview scrolling.

by 돼지왕왕돼지 2013. 9. 23.
반응형


 android, how to disable gridview scrolling

 

[android] how to disable gridview scrolling.


[En]

Not only the GridView but also all kinds of AdapterView can be adjusted not to scroll by making new class which extends the view. You can do nothing in the onTouchEvent and onInterceptTouchEvent function which are responsible for taking MotionEvent and do scrolling logic.


[Kr]

GridView 뿐만 아니라 모든 AdapterView 들의 Scrolling 을 막는 데는 아래와 같이 해당 View 를 extends 해준다음 Scrolling 을 위한 MotionEvent 를 잡아먹는 onTouchEvent 와 onInterceptTouchEvent 부분을 override 하여 아무것도 안 해주면 된다.


ex)

public static class MyGridView extends GridView{

public MyGridView(Context context) {

super(context);

}


public MyGridView(Context context, AttributeSet attrs) {

super(context, attrs);

}

public MyGridView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

}


@Override

public boolean onTouchEvent(MotionEvent ev) {

if ( ev.getAction() == MotionEvent.ACTION_MOVE) return true;

return super.onTouchEvent(ev);

}

}







반응형

댓글0