The life cycle of view in Android

Source: Internet
Author: User

See also: http://ndquangr.blogspot.jp/2013/04/android-view-lifecycle.html

Category Methods Description
Creation Constructors There is a form of the constructor that was called when the view was created from code and a form that was called when T He view is inflated from a layout file. The second form should parse and apply any attributes defined in the layout file.
onFinishInflate() Called after a view and all of its children have been inflated from XML.
Layout onMeasure(int, int) called to determine the size requirements for this view and all of its children.
onLayout(boolean, int, int, int, int) Called when the This view should assign a size and position to all of its children.
onSizeChanged(int, int, int, int) Called when the size of this view has changed.
Drawing onDraw(android.graphics.Canvas) Called when the view should to render its content.
Eventprocessing onKeyDown(int, KeyEvent) Called when a new hardware key event occurs.
onKeyUp(int, KeyEvent) Called when a hardware key up event occurs.
onTrackballEvent(MotionEvent) Called when a trackball motion event occurs.
onTouchEvent(MotionEvent) Called when a touch screen motion event occurs.
Focus onFocusChanged(boolean, int, android.graphics.Rect) Called when the view gains or loses focus.
onWindowFocusChanged(boolean) Called when the window containing the view gains or loses focus.
Attaching onAttachedToWindow() Called when the view was attached to a window.
onDetachedFromWindow() Called when the view was detached from its window.
onWindowVisibilityChanged(int) Called when the visibility of the window containing the view had changed.

* [Change of visibility]
*--structure view
*--Onfinishinflate
*--Onattachedtowindow
*--Onmeasure
*--onsizechanged
*--OnLayout
*--OnDraw
*--Ondetackedfromwindow
*
*
*
1. Onfinishinflate () Fires when all the child controls in view are mapped to XML.
2, onmeasure (int, int) determines the size of all child elements.
3, OnLayout (boolean, int, int, int, int) is triggered when view allocates the size and position of all child elements.
4, onsizechanged (int, int, int, int) is triggered when the size of the view changes.
5. OnDraw (Canvas) view renders the details of the content.
6, OnKeyDown (int, keyevent) have the button pressed and then triggered.
7, onKeyUp (int, keyevent) is triggered when the button is pressed and bounced.
8, Ontrackballevent (motionevent) trajectory ball event.
9, Ontouchevent (motionevent) touch screen event.
10, Onfocuschanged (boolean, int, Rect) triggers when view Gets or loses focus.
11, Onwindowfocuschanged (Boolean) Triggers when a window contains a view that gets or loses focus.
12, Onattachedtowindow () triggers when view is attached to a window.
13. Ondetachedfromwindow () Triggers when view leaves an attached window, Android123 hints that the method and Onattachedtowindow () are reversed.
14, onwindowvisibilitychanged (int) is triggered when the visible view that is contained in the window changes.

The life cycle of view in Android

Related Article

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.