欢迎来到皮皮网官网

【胜率 公式 源码】【平台源码克隆】【android体彩源码】android touch 源码

时间:2024-12-29 09:10:07 来源:深圳源码照明

1.android onTouchEvent和setOnTouchListener中onTouch的区别
2.Android onTouchEvent和setOnTouchListener中onTouch的区别

android touch 源码

android onTouchEvent和setOnTouchListener中onTouch的区别

       åœ¨dispatch过程中会先去check已经被set的OnTouchListener,如果在OnTouchListener的onTouch里头return true了,就会直接return true,不再走view本身的onTouchEvent。具体看代码:

        /

**

        * Pass the touch screen motion event down to the target view,源码胜率 公式 源码 or this

        * view if it is the target.

       

*

        * @param event The motion event to be dispatched.

        * @return True if the event was handled by the view, false otherwise.

        */

        public boolean dispatchTouchEvent(MotionEvent event) {

        if (mInputEventConsistencyVerifier != null) {

        mInputEventConsistencyVerifier.onTouchEvent(event, 0);

        }

        if (onFilterTouchEventForSecurity(event)) {

        //noinspection SimplifiableIfStatement

        ListenerInfo li = mListenerInfo;

        if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED

        && li.mOnTouchListener.onTouch(this, event)) {

        return true;

        }

        if (onTouchEvent(event)) {

        return true;

        }

        }

        if (mInputEventConsistencyVerifier != null) {

        mInputEventConsistencyVerifier.onUnhandledEvent(event, 0);

        }

        return false;

        }

Android onTouchEvent和setOnTouchListener中onTouch的区别

       onTouchEvent是用来监听整个屏幕的滚动,setOnTouchListener是监听某个控件的。但setOnTouchListener监听最外层布局的滚动时,他们的就一样了。

copyright © 2016 powered by 皮皮网   sitemap