In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "android development of onInterceptTouchEvent, onTouchEvent and onTouch example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "android development onInterceptTouchEvent, onTouchEvent and onTouch sample analysis" this article.
1. OnTouch
OnTouch is a method in the OnTouchListener interface of View that handles events in which View and its subclasses are handled by touch. Of course, the premise is that the touch time can be passed to the specified view. Q1: why can't it be delivered?
/ * * Interface definition for a callback to be invoked when a touch event is * dispatched to this view. The callback will be invoked before the touch * event is given to the view. * / public interface OnTouchListener {/ * * Called when a touch event is dispatched to a view. This allows listeners to * get a chance to respond before the target view. * * @ param v The view the touch event has been dispatched to. * @ param event The MotionEvent object containing full information about * the event. * @ return True if the listener has consumed the event, false otherwise. * / boolean onTouch (View v, MotionEvent event);}
II. OnTouchEvent
OnTouchEvent is also a method defined in view. Handles gesture events passed to view. The types of gesture events include four types of ACTION_DOWN,ACTION_MOVE,ACTION_UP,ACTION_ call events.
/ * Implement this method to handle touch screen motion events. * * @ param event The motion event. * @ return True if the event was handled, false otherwise. * / public boolean onTouchEvent (MotionEvent event) {. …… }
Once the onTouchEvent method is called and returns true, the gesture event ends and is not passed down to the child control. When will Q2:onTouchEvent be called?
III. OnInterceptTouchEvent
OnInterceptTouchEvent is defined in ViewGroup. The layout layout class in Android generally inherits this class. OnInterceptTouchEvent is used to intercept gesture events, and each gesture event calls onInterceptTouchEvent first.
Public boolean onInterceptTouchEvent (MotionEvent ev) {return false;}
If this method returns false, the gesture event is passed to the child control; if true is returned, the onTouchEvent method is called.
These are all the contents of the article "sample Analysis of onInterceptTouchEvent, onTouchEvent and onTouch in android Development". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.