2013-04-03 58 views
2

我有一個列表視圖,其中包含約30項。當我向下滾動它時,它會進入列表的最底部,並且在用戶觸摸列表時不會停止。當用戶觸摸列表時停止在列表視圖中滾動 - android

是否有停止滾動的方法時,列表視圖中被觸摸,並在同一時間的用戶應該能夠使用onItemClick導航(已處理)..

謝謝!

+0

這是默認的行爲...你定製的Android以任何方式? –

回答

6

試試這個平滑滾動

@Override 
public boolean onTouchEvent(MotionEvent ev) 
{ 
switch (ev.getAction()) 
    { 
    case MotionEvent.ACTION_UP: this.smoothScrollBy(0, 0); 
    break; 
    } 
    return super.onTouchEvent(ev); } 
0

通過參考尼廷·古普塔答案,我想出了我自己:

公共類OnTouchListenr實現OnTouchListener {

 @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      if(event.getAction()==MotionEvent.ACTION_DOWN) 
       { 
        businessResultListView.smoothScrollBy(0, 0); 
        return true; 

       } 

      return false; 
     }   

    } 

然後我設置了OnTouchListner上像這樣的列表視圖:

 businessResultListView.setOnTouchListener(new OnTouchListenr()); 
0

覆蓋dispatchTouchEvent在你的列表視圖

@Override 
public boolean dispatchTouchEvent(MotionEvent ev){ 
    if(ev.getAction()==MotionEvent.ACTION_MOVE){ 
     return true; 
    }return super.dispatchTouchEvent(ev); 
} 
相關問題