Preface
Keywords: Android. widget. analogclock, Android 2.2 R1 analogclock, analogclock API
This chapter translates Android. widget. analogclock into a clock/analog clock. Starting from this chapter, the translation series officially changed to "android Chinese ?", For example, the current series of "android Chinese API", in addition to someone in the translation test related content, welcome to participate in the android API Chinese translation operations, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog: http://www.cnblogs.com
Farmer's uncle: http://www.cnblogs.com/over140/
Version
Android 2.2 r1
Body
I. Structure
Public class analogclock extends View
Java. Lang. Object
Android. View. View
Android. widget. analogclock
Ii. Category Overview
This is a analog clock control with the hour and minute hands.
Iii. Protected Methods
Protected void onattachedtowindow ()
Called when a view (analogclock) is attached to a form. When called, the view is displayed on the surface of the form and is drawn. Ensure that this method is called before ondraw (canvas), but it can be called any time before or after ondraw (INT, INT.
Protected void ondetachedfromwindow ()
It is called when a view (digitalclock) is detached (removed) from a form, and a view is no longer drawn on the form surface.
Protected void ondraw (canvas)
Implement your own rendering.
Parameters
Canvas draws the background on the canvas
Protected void onmeasure (INT widthmeasurespec, int heightmeasurespec)
Measure this view to determine the height and width of its content. This method is called Through measure (INT, INT) and should be rewritten by subclass to improve the efficiency and accuracy of content measurement.
Convention: When this method is overwritten, you must call setmeasureddimension (INT, INT) to store the height and width of the measured view. Otherwise, an illegalstateexception is thrown through measure (INT, INT. It is an effective method to call the onmeasure (INT, INT) method of the parent class.
The implementation of the parent class is based on the Default background size, unless measurespec (measurement rules) allows a larger background. To better measure the content subclass, override onmeasure (INT, INT ).
If this method is overwritten, The subclass has the responsibility to ensure that the height and width of the measurement are at least the minimum width and height of the view (getsuggestedminimumheight () and getsuggestedminimumwidth ()).
Parameters
Widthmeasurespec because the parent class has horizontal space requirements, see view. measurespec.
Heightmeasurespec because the parent class has vertical space requirements, see view. measurespec.
Protected void onsizechanged (int w, int H, int oldw, int oldh)
Called when the View Size changes during layout. If only the view is added, the old value 0 is displayed during the call. (Note: when added to the view, the values of oldw and oldh are 0)
Parameters
W view current width
H view current height
Previous width of the oldw View
Previous height of the oldh View
Iv. PDF download
Http://download.csdn.net/source/2772172 (csdn)
End
At present, there are 15 members in the translation group, and the plan is in progress. We look forward to the arrival of 51 members on that day. You are welcome to join us.