Here is code example:
public class SwipeRelativeLayout extends RelativeLayout {
private String TAG = "SwipedListView";
private MotionEvent previous = null;
private MotionEvent start = null;
public SwipeRelativeLayout(Context context) {
super(context);
}
public SwipeRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
int action = ev.getAction();
String eventType = "";
switch (action)
{
case MotionEvent.ACTION_CANCEL:
{
eventType = "ACTION_CANCEL";
} break;
case MotionEvent.ACTION_DOWN:
{
eventType = "ACTION_DOWN";
} break;
case MotionEvent.ACTION_UP:
{
eventType = "ACTION_UP";
} break;
case MotionEvent.ACTION_MOVE:
{
eventType = "ACTION_MOVE";
} break;
}
Log.e(TAG, "onInterceptTouchEvent() Type = " + eventType + " X = " + Float.toString(ev.getRawX()) + " Y = " + Float.toString(ev.getRawY()));
return true;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction() ;
String eventType = "";
switch (action)
{
case MotionEvent.ACTION_CANCEL:
{
eventType = "ACTION_CANCEL";
} break;
case MotionEvent.ACTION_DOWN:
{
eventType = "ACTION_DOWN";
} break;
case MotionEvent.ACTION_UP:
{
eventType = "ACTION_UP";
} break;
case MotionEvent.ACTION_MOVE:
{
eventType = "ACTION_MOVE";
} break;
}
Log.e(TAG, "onTouchEvent() Type = " + eventType + " X = " + Float.toString(event.getRawX()) + " Y = " + Float.toString(event.getRawY()));
return false;
}
}
Could somebody explain, why I can see onle ACTION_DOWN event into onInterceptTouchEvent()? As has been told in the point 3 at developers.android.com
For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
I made this, but stil can't see events into onInterceptTouchEvent(), except ACTION_DOWN