Code example for MotionEvent

Methods: getActiongetActionIndexgetPointerId

0
 
    private String getEvent(MotionEvent event)
    { 
 
	StringBuilder sb = new StringBuilder();
	int action = event.getAction();
	int actionCode = action & MotionEvent.ACTION_MASK;
	//sb.append("code").append( actionCode ); 
	if (actionCode == MotionEvent.ACTION_MOVE) {
	    sb.append("{move:[").append(moveBuffer).append("]}");
	} else if (actionCode == MotionEvent.ACTION_POINTER_DOWN
		|| actionCode == MotionEvent.ACTION_DOWN) {
	    sb.append("{down:").append(moveBuffer).append("}");
	} else if (actionCode == MotionEvent.ACTION_POINTER_UP
		|| actionCode == MotionEvent.ACTION_UP) {
	    sb.append("{up:").append(event.getPointerId(event.getActionIndex())).append("}");
	} else if (actionCode == MotionEvent.ACTION_CANCEL) {
	    sb.append("{cancel:").append(event.getPointerId(event.getActionIndex()));
	} 
 
	return sb.toString();
    } 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE