The number of execution smoothing for each function in Android view

Source: Internet
Author: User

This is like the life cycle of the activity, and if we are going to use a custom view, then it is necessary to understand the order of execution of the functions that can be overridden by the view . Don't say much nonsense, take the usual 5 functions as an example, see below:

1  Packagecom.example.pulltorefreshtest;2 3 ImportAndroid.content.Context;4 ImportAndroid.graphics.Canvas;5 ImportAndroid.util.AttributeSet;6 ImportAndroid.util.Log;7 ImportAndroid.view.View;8 9 /**Ten * Created by Administrator on 2015/7/12. One  */ A  Public classTestViewextendsView { -      PublicTestView (Context context, AttributeSet attrs) { -         Super(context, attrs); the     } -  - @Override -     protected voidOnmeasure (intWidthmeasurespec,intHeightmeasurespec) { +LOG.D ("------", "---onmeasure"); -         Super. Onmeasure (Widthmeasurespec, heightmeasurespec); +     } A  at @Override -     protected voidOnLayout (BooleanChangedintLeftintTopintRightintbottom) { -LOG.D ("------", "---onlayout"); -         Super. OnLayout (changed, left, top, right, bottom); -     } -  in @Override -     protected voidonfinishinflate () { toLOG.D ("------", "---onfinanshinflate"); +         Super. Onfinishinflate (); -     } the  * @Override $     protected voidOnDraw (canvas canvas) {Panax NotoginsengLOG.D ("------", "---onDraw"); -         Super. OnDraw (canvas); the     } +  A @Override the     protected voidOnsizechanged (intWintHintOLDW,intOLDH) { +LOG.D ("------", "---onsizechanged"); -         Super. Onsizechanged (W, H, OLDW, OLDH); $     } $}

Operation Result:

07-12 13:44:45.413  23734-23734/? d/------:---onfinanshinflate07-12 13:44:45.443  23734-23734/? d/------:---onmeasure07-12 13:44:45.493  23734-23734/? d/------:---onsizechanged07-12 13:44:45.493  23734-23734/? d/------:---onlayout07-12 13:44:45.503  23734-23734/? d/------:---onmeasure07-12 13:44:45.503  23734-23734/? d/------:---onlayout07-12 13:44:45.503  23734-23734/? d/------:---OnDraw

  

The number of execution smoothing for each function in Android view

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.