我正在努力寻找一种可靠的方法,让用户能够长时间按下gridview项目长达15秒,并且当用户的手指被释放时,总是会收到ACTION_UP。一旦检测到长按,我也想允许无限制的移动。除了手指被抬起之外,还应该中断此过程。
这是一个额外的信息,这是一个在寻呼机内部的网格视图,但我想做的是可能的其他应用程序完美地做这样的事情
这是我最近的尝试,但我已经尝试了几十次:
public class recordVideo implements OnLongClickListener,OnTouchListener {
private int position;
private String clicked_uid;
public recordVideo(int position){
this.position=position;
}
@Override
public boolean onLongClick(View v){
//do things
// Do something when your hold starts here.
isSpeakButtonLongPressed = true;
Log.i("START_RECORD","longClick");
return true;
}
@Override
public boolean onTouch(View pView, MotionEvent pEvent) {
pView.onTouchEvent(pEvent);
if (pEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.i("START","video");
}
// We're only interested in when the button is released.
if (pEvent.getAction() == MotionEvent.ACTION_UP) {
// We're only interested in anything if our speak button is currently pressed.
Log.i("STOP_RECORD","video");
if (isSpeakButtonLongPressed) {
// Do something when the button is released.
isSpeakButtonLongPressed = false;
// Log.i("STOP_RECORD","video");
}
}
return true;
}