[Andorid X Project Notes] disable the Fling function of ListView (1)

Source: Internet
Author: User

 

 

Preface

The new project is under intense development. It is estimated that the first version will be developed in two months. I am in charge of Android development. Due to the inconvenience, this series will be named "X project notes ", the project name will be published after the project ends. This series mainly records and shares the Problems and Solutions encountered in the "X Project.


Statement
Welcome to repost, but please keep the original source of the article :) blog Park: http://www.cnblogs.com

Farmer's uncle: http://over140.cnblogs.com

 

Body

Previously encountered abnormal requirements: Android controls the ScrollView sliding speed. This time, it is a self-raised requirement. The Fling function of ListView is disabled, that is, the fast sliding function, and the code is directly added:

/** Gesture Recognition class */
Private class TouchGesture extends SimpleOnGestureListener {

/** Quick scroll */
@ Override
Public boolean onFling (MotionEvent e1, MotionEvent e2, float velocityX, float velocityY ){
Return true;
}

}

Private OnTouchListener mOnListViewTouchListener = new OnTouchListener (){

@ Override
Public boolean onTouch (View v, MotionEvent event ){
If (mTouchGesture. onTouchEvent (event ))
Return true;
Return false;
}
};

Code Description:

Call setOnTouchListener of ListView to bind mOnListViewTouchListener. The key point is to return true in the onFling method, which means to consume the Fling event and stop uploading the event chain.

 

End

I found that I have already written several series. Haha, it seems that some of them are coming to an end ~~ Not afraid ~ I continued to launch a new series, but basically reflected my work conditions.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.