Simple usage instructions for Android Studio using ButterKnife

I'm working on a project recently, and I don't want to use the previous findViewById to get the controls. Use a plug-in that is convenient for writing code and makes the code concise to get the control. This plug-in is ButterKnife .

1. Click File--Settings--Plugins in the upper left corner, then enter Zelezny in the input box and click Download, restart AS to download the plugin.

2. Add the following sentence in the red box to build.gradle--dependencies, otherwise even if you download it, it will not be available in the program.


3. Click on your own layout file, then right-click to select Generate in Figure 1 below; then select Figure 2 Generate ButterKnife Injections, Figure 3 appears, select the controls you need and tick them, and click Confirm to see what you just selected in the program The controls are bound, as shown in Figure 4.

                                Figure 1

                            Figure II

                                                                Figure 3

                                            Figure 4

The above is the specific usage of ButterKnife. Comments are welcome.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883066&siteId=291194637