Gallery 判斷 scroll 開始和中止

想在Gallery 開始滑動時和滑動結束時作一些處理,就須要知道滑動開始和中止的時機ide

1.開始的時機this

Gallery mCoverFlowView = new  Gallery(context);spa

final GestureDetectorCompat mGestureDetectorCompat = new GestureDetectorCompat(this, this); it

mCoverFlowView.setOnTouchListener(new OnTouchListener() {io

 

@Overrideevent

public boolean onTouch(View v, MotionEvent event) {class

return mGestureDetectorCompat.onTouchEvent(event);List

}float

});tab

  

});

 

而後能夠在OnGestureListener中的

@Override

public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,

float distanceY) {

//添加滑動開始時  處理邏輯

return false;

}

 

2.判斷gallery  什麼時候中止

mCoverFlowView.setCallbackDuringFling(false);  

mCoverFlowView.setOnItemSelectedListener(new OnItemSelectedListener() {

 

@Override

public void onItemSelected(AdapterView<?> parent, View view,

int position, long id) {

  //添加滑動結束 處理邏輯

}

 

@Override

public void onNothingSelected(AdapterView<?> parent) {

 

}

});

相關文章
相關標籤/搜索