This article is from the study notes on "Mr. Jin's Computer Self-study Website" , and it is strongly recommended! The content is very good. You can learn if you need it~
table of Contents
Three, Activity and layout files
Five, findViewById alternative
1. Activity overview
2. Layout overview
Three, Activity and layout files
It is recommended not to modify the base class of activity to prevent the display effect of different versions from being different.
Associating activities and layouts: use setContentView() in the activity code
The control elements in the layout all have corresponding view objects~
The efficiency of fingViewById is not high~ If you need to call on a large scale in the project, you need to optimize it yourself...
There are two ways to hook a control to an activity:
1. Add a listener to the control object directly in the activity code
2. In the xml file, add the onclick attribute to the corresponding control (declarative)
Get the reference of the corresponding control object through findViewById, but you can also directly use the id value of the control as the reference of the object in Kotlin !
4. Resources in the project
Five, findViewById alternative
Six, summary