I have created two buttons in a gridview.
I wish to achieve the following aim but no idea which method should be used?
First i touch on the 1st button, toast 1 msg will be shown. By swiping my finger over to the 2nd button 开发者_JS百科without lifting up my finger, toast 2 msg will be shown.
When i lift up my finger from the screen, toast 3 msg will be shown.
Maybe can help u
gridview.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
gridview.requestFocusFromTouch();
gridview.setSelection(gridview.pointToPosition((int)event.getX(),(int)event.getY()));
return true;
}
if(event.getAction() == MotionEvent.ACTION_UP){
gridview.clearFocus();
return true;
}
return false;
}
});
精彩评论