April, May is much busier than before, understand a lot, also changed a lot, today is still forced to work overtime, the job at hand is almost done, think it has been a long time without learning new knowledge. Lazy and stupid, but also do not want to live up to the kindness of friends, Butter Knife is a friend introduced the more useful class library. Today with a bit or very useful although and xutils notes very acquaintance, but if the project network request does not use Xutils, you can use it, want to say its use method is really simple, all understand it.
Configuration:
when configured with Gradle, add:
Compile ' com.jakewharton:butterknife:6.1.0 '
Note is added in the module: app 's Gradle file.
Plus you don't have to run any commands, just sync it and see Butterknife in external libraries.
Function:
1. Reduce Findviewbyid ()
can also be used in 2.fragment
The 3.iewHolder class adds a construction method with a parameter view, marking each field with annotations, and no longer having to call the Findviewbyid () method in the GetView () method.
4. Reduce Setonclicklistener ()
Of course, there are many more useful methods, I picked a few often used to study a bit, we are interested in learning other, such as the Reset () method can be used to inject Butterknife view reference set to null and so on. Everyone has a good weekend.
Use of Butter knife (Android Studio only)