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.
Import Android.content.context;import Android.util.attributeset;import Android.view.motionevent;import Android.widget.listview;public class Scrolldisabledlistview extends ListView {private int mposition; Public Scrolldisabledlistview (Context context) {super (context); } public Scrolldisabledlistview (context context, AttributeSet Attrs) {Super (context, attrs); } public Scrolldisabledlistview (context context, AttributeSet attrs, int defstyle) {Super (context, Attrs, DefS Tyle); } @Override public boolean dispatchtouchevent (Motionevent ev) {final int actionmasked = ev.getactionmasked ( ) & Motionevent.action_mask; if (actionmasked = = Motionevent.action_down) {//record position when finger is pressed mposition = pointtoposition ((int) ev.ge TX (), (int) ev.gety ()); return super.dispatchtouchevent (EV); } if (actionmasked = = Motionevent.action_move) {//key place, ignore MOVE event//ListView ONtouch does not get the move event so scrolling will not occur return true; }//If the finger is lifted (actionmasked = = Motionevent.action_up | | actionmasked = = motionevent.action_cancel) { The finger is pressed and lifted in the same view, handed to the parent control handle, which is a click event if (pointtoposition (int) ev.getx (), (int) ev.gety ()) = = Mposit ION) {super.dispatchtouchevent (EV); } else {//If the finger has moved out of the pressed item, the description is scrolling, the item pressed state setpressed (false) is cleared; Invalidate (); return true; }} return super.dispatchtouchevent (EV); }}
Resources:
Disable Scrolling in Android ListView
Disable Scrolling in ListView
Reprint please specify the source:
Android Settings ListView Non-scrollable
http://blog.csdn.net/androiddevelop/article/details/38815493
Android implements a ListView non-scrolling effect