我想长时间悬停图像,我尝试了这个:
image.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
Long start = null, end = null;
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
start = System.currentTimeMillis();
//do somethins....
break;
case MotionEvent.ACTION_DOWN:
end = System.currentTimeMillis();
//do something...
break;
}
if(end-start<1003){
//do something ....
}
return true;
}
});
但它给了我一个空异常,我该怎么做才能让它工作?
提前致谢,