2011-01-13 2 views

答えて

0

私はそれを達成しました。

Coordinate coordinate = new Coordinate(); 

@Override 
public boolean onTouch(View v, MotionEvent event) { 

     switch (event.getAction() & MotionEvent.ACTION_MASK) { 

     case MotionEvent.ACTION_DOWN: 

      coordinate.setStartX(event.getX()); 
      Log.i("start X" , String.valueOf(event.getX())); 
      break; 

     case MotionEvent.ACTION_UP: 
     case MotionEvent.ACTION_POINTER_UP: 
     case MotionEvent.ACTION_MOVE: 
      coordinate.setEndX(event.getX()); 
      Log.i("end X" , String.valueOf(event.getX())); 
      break; 
     }   
    } 
    return true; 
} 

private class Coordinate { 

    private float startX; 
    private float endX; 

    /** 
    * @return the startX 
    */ 
    public float getStartX() { 
     return startX; 
    } 
    /** 
    * @param startX the startX to set 
    */ 
    public void setStartX(float startX) { 
     this.startX = startX; 
    } 
    /** 
    * @return the endX 
    */ 
    public float getEndX() { 
     return endX; 
    } 
    /** 
    * @param endX the endX to set 
    */ 
    public void setEndX(float endX) { 
     this.endX = endX; 
    }  
} 
関連する問題