The desired effect is that the ListView cannot scroll, but the biggest problem with the ListView item is also the Click event, if you do not need to click the event that is simple, directly set listview.setenable (false);
If you still need to click events, scrolling and clicking are all managed in the ListView Touch processing mechanism.
The ListView Click event is the processing logic of the multiplexed viewgroup, which triggers a click event when the user clicks on the view and moves a small distance between pressing and lifting the finger to meet the time limit of the Click event.
The ListView scrolling event is handled by itself, and there are two criteria for judging when the user triggers a move event and the swipe exceeds the touch slop distance or the sliding speed exceeds the threshold to be judged as a scrolling event.
1 ImportAndroid.content.Context;2 ImportAndroid.util.AttributeSet;3 Importandroid.view.MotionEvent;4 ImportAndroid.widget.ListView;5 6 Public classScrolldisabledlistviewextendsListView {7 8 Private intmposition;9 Ten PublicScrolldisabledlistview (Context context) { One Super(context); A } - - PublicScrolldisabledlistview (Context context, AttributeSet attrs) { the Super(context, attrs); - } - - PublicScrolldisabledlistview (context context, AttributeSet attrs,intDefstyle) { + Super(context, attrs, defstyle); - } + A @Override at Public Booleandispatchtouchevent (motionevent ev) { - Final intactionmasked = ev.getactionmasked () &Motionevent.action_mask; - - if(actionmasked = =Motionevent.action_down) { - //record the position of the finger when it is pressed -Mposition = Pointtoposition ((int) Ev.getx (), (int) ev.gety ()); in return Super. dispatchtouchevent (EV); - } to + if(actionmasked = =motionevent.action_move) { - //The most critical place to ignore the move event the //ListView Ontouch does not get a move event so scrolling is not occurring * return true; $ }Panax Notoginseng - //when your finger is lifted the if(actionmasked = =motionevent.action_up +|| actionmasked = =motionevent.action_cancel) { A //The finger is pressed and lifted in the same view, handed to the parent control to handle, which is a click event the if(Pointtoposition (int) Ev.getx (), (int) ev.gety ()) = =mposition) { + Super. dispatchtouchevent (EV); -}Else { $ //if the finger has moved out of the pressed item, the description is scrolling behavior, cleaning the item pressed state $Setpressed (false); - invalidate (); - return true; the } - }Wuyi the return Super. dispatchtouchevent (EV); - } Wu}
(Transferred from: http://blog.csdn.net/androiddevelop/article/details/38815493)
Android implements a ListView non-scrolling effect