2013-03-14 18 views
0

我必須顯示一個圖形,當您將手指拖過它時,視圖應顯示數據。android通過拖動手指顯示數據

我已經看到,這是可能的,當你點擊「onclicklistener」,但它也有可能以這種方式嗎?

謝謝!

+0

您是否正在尋找類似的'GestureListener'利用''ACTION_MOVE'的MotionEvents'? http://developer.android.com/reference/android/view/GestureDetector.html – Grambot 2013-03-14 19:30:27

回答

0

使用

 @Override 
     public boolean onTouchEvent(MotionEvent event) { 
    float x = event.getX(); 
     float y = event.getY(); 
    if (event.getAction() == MotionEvent.ACTION_DOWN) { 
    //Do something interesting 
    }else if (event.getAction() == MotionEvent.ACTION_MOVE) { 
    //Do something exciting 
    }else if (event.getAction() == MotionEvent.ACTION_UP) { 
//Do something boring 
}