Android ListView onTouchEvent doesn't always give ACTION_DOWN -
my problem when try drag item in listview, don't action_down event. got lots of action_move events , 1 action_up event. not case. got action_down 3 times. confused me.
i looked @ similar questions it's answers seems not fit mine . can think of why happening?
thanks
//list_client -- listview list_client.setontouchlistener(new view.ontouchlistener() { float f1 = -1, f2 = -1 ; @override public boolean ontouch(view v, motionevent event) { switch(event.getaction()){ case motionevent.action_down: f1 = event.getrawy(); break; case motionevent.action_move: f2 = event.getrawy(); if(f2 - f1 > 50){ if(view.visible != rl_search_and_add.getvisbility() && ){ rl_search_and_add.setvisibility(view.visible); } f1 = f2; }else if (f2 - f1 < -50){ rl_search_and_add.setvisibility(view.gone); f1 = f2; } break; case motionevent.action_up: f1 = -1; f2 = -1; break; } return false; } });
there several reasons behavior.
- it possible user missed list bit ,
motionevent.action_down
been handled other component, how ever user continue dragging , hit list view area, receivedmotionevent.action_move
actions. - another possibility that, had many events, , been moved historical event, , received latest event. can use historical methods of motionevent see them.
Comments
Post a Comment