Butterknife
This open source library can let us from a large number of Findviewbyid () and Setonclicktlistener (), its impact on performance is very small (see Butter knife Source code, The implementation of its custom annotations is limited to retentionpolicy.class, that is, to compile the. CLASS file so that it works, without additional performance at run time, which is done by automatically generating Java code in Java annotations, which also has a significant disadvantage, That is, the readability of the code is somewhat poor.
1. Installing plugins
Open the Studio Setup interface, select Plugins,browse repositories ..., search Butterknife, find the Post
Select Install and restart studio after the installation is complete.
2. Project Setup
Adding a local warehouse to the build.gradle of the project
1 dependencies { 2 classpath ' com.neenbedankt.gradle.plugins:android-apt:1.8 ' 3 Classpath ' com.android.tools.build:gradle:2.2.0 ' 4 5 } 6 7 allprojects { 8 repositories { 9 jcent ER () 10 Mavencentral () 11 12 } 13 }
Last synchronization
3. Module settings
Add on Header
Apply plugin: ' com.android.application 'android-apt '
adding in dependent libraries
Apply plugin: ' android-apt 'com.jakewharton:butterknife-compiler:8.4.0 '
Last Sync
4. Use
In any layout, right-click the layout file (r.layout.activity_main) in your code, select Generate, and then select Butter.
Or, after you move the cursor to the layout file, press Alt+insert (Eclipse Accelerator), and then select the butter
The Open interface selects the view or onclick that requires annotations, and it can also generate Viewholder.
Android Studio Common Plugins