Use Custom View

A constructor on the Custom View

java in to the constructor just calls, not inherited. Android UI frame because the entire system is provided, thus the constructor to be written in the format required by it, and that is the same as the constructor View.

Custom View in order to achieve their own with View-argument constructor, because the general will be defined in xml View, this constructor is called sdk.

There are the following conclusions:

First, a new code directly Custom View example, when the first constructor calls;

Second, call the Custom View in the layout xml file in time, we will call the second constructor;

Third, call in xml Custom View layout file, and Custom View tab there custom properties, is here called the second constructor;

Fourth, the two constructors need to call in their constructor.

 

The first parameter is the constructor context of its use of Activity Context.

 

 

 

 

 

References:

1 Android Custom constructor Detailed View

https://blog.csdn.net/wzy_1988/article/details/49619773

2 Android View from implementation-defined, and takes you step by step understanding of View (D)

https://blog.csdn.net/guolin_blog/article/details/17357967

3 taught you how to write a complete custom View

https://juejin.im/entry/5949d4d85c497d006b08e08b 

Guess you like

Origin www.cnblogs.com/hustdc/p/11577682.html