长按及松开处理
// 长按触发handle
final Handler handler = new Handler();
final Runnable mLongPressed = new Runnable() {
public void run() {
// 长按处理
}
};
// 手势操作处理
this.findViewById(R.id.img_record).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN)
handler.postDelayed(mLongPressed, 1000);
if(event.getAction() == MotionEvent.ACTION_UP) {
handler.removeCallbacks(mLongPressed);
// 放开处理
}
return true;
}
});