android中view的生命週期

請參見:http://ndquangr.blogspot.jp/2013/04/android-view-lifecycle.htmlhtml

Category   Methods Description
Creation   Constructors There is a form of the constructor that are called when the view is created from code and a form that is called when the 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 has 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 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 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 is attached to a window.
onDetachedFromWindow() Called when the view is detached from its window.
onWindowVisibilityChanged(int) Called when the visibility of the window containing the view has changed.

 

* [改變可見性]* --> 構造View* -->  onFinishInflate* -->  onAttachedToWindow* -->  onMeasure* -->  onSizeChanged* -->  onLayout* -->  onDraw* -->  onDetackedFromWindow***    一、onFinishInflate() 當View中全部的子控件均被映射成xml後觸發 。    二、onMeasure( int , int ) 肯定全部子元素的大小 。    三、onLayout( boolean , int , int , int , int ) 當View分配全部的子元素的大小和位置時觸發 。    四、onSizeChanged( int , int , int , int ) 當view的大小發生變化時觸發 。    五、onDraw(Canvas) view渲染內容的細節。    六、onKeyDown( int , KeyEvent) 有按鍵按下後觸發 。    七、onKeyUp( int , KeyEvent) 有按鍵按下後彈起時觸發 。    八、onTrackballEvent(MotionEvent) 軌跡球事件 。    九、onTouchEvent(MotionEvent) 觸屏事件 。    十、onFocusChanged( boolean , int , Rect) 當View獲取或失去焦點時觸發 。    十一、onWindowFocusChanged( boolean ) 當窗口包含的view獲取或失去焦點時觸發 。    十二、onAttachedToWindow() 當view被附着到一個窗口時觸發 。    1三、onDetachedFromWindow() 當view離開附着的窗口時觸發,Android123提示該方法和 onAttachedToWindow() 是相反的。    1四、onWindowVisibilityChanged( int ) 當窗口中包含的可見的view發生變化時觸發。
相關文章
相關標籤/搜索