Android studio uses butterknife and zelezny’s methods

preface

Butterknife is a view injection framework focusing on Android, which can reduce a large number of findviewbyid and setonclicklistener codes and visualize one click generation.

It has the following advantages:

1. Powerful view binding and click event processing functions simplify the code and improve the development efficiency. 2. It is convenient to deal with the viewholder binding problem in the adapter. 3. The runtime will not affect the app efficiency and easy to use and configure. 4. The code is clear and readable

Configuring butterknife for Android studio

First step

Step 2

Configure build.gradle for project

Add in dependencies

Step 3

Configure build.gradle of module

Add the following on the outside:

In dependencies:

Here, the basic introduction is completed, and then apply it.

Using the butterknife annotation control:

The above code is the basic control annotation, which is very convenient to use.

Here, I will not explain the role of each method one by one. Those interested can consult the data themselves.

Now look at the zelezny plug-in used with butterknife:

I have installed it here. If it is not installed, you will be prompted to install it. After installation, Android studio will be restarted.

Right click on the layout file to enter generate, and you will see the plug-in as shown in the figure, which proves that the plug-in installation is successful.

After clicking:

The location code is generated by the plug-in. Is it very convenient? I hope it will help you. If you have different opinions, please leave a message and exchange. I will pay attention to it often.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>