2013-06-12 79 views
0

我有一個手勢監聽器干擾listView滾動。 「在手指放下」動作一旦開始就不會停止滾動listView,所以我打算將它寫入代碼中。onDown時停止ListView滾動

我找不到一個方法來停止listView時,手指觸摸列表?

我想在這裏做:

public boolean onDown(MotionEvent e) { 

     // Stop Scroll here! 

     return true; 
    } 

這可能

回答

1

使用此:

listView.setOnTouchListener(new OnTouchListener() { 

public boolean onTouch(View v, MotionEvent event) { 
    if (event.getAction() == MotionEvent.ACTION_MOVE) { 
     return true; // Indicates that this has been handled by you and will not be forwarded further. 
    } 
    return false; 
} 

});

然後ListView將對點擊作出反應,但不會改變滾動位置。

從這個solution

+0

由於服用;到處都是我想說的是我需要刪除'@ Override'。這個方法放在哪裏?我正在使用'ListFragment'。 – KickingLettuce

+1

我剛剛編輯了我的答案。所以你可以在你的listView實例上匿名實現它。 –

+0

通過在listview類中使用嵌套類無法真正理解您的目標。在這裏創建新的問題,這樣其他人可能會幫助你。我也會看看,並儘可能地幫助你。 –