Butterknife is a light weight library to inject views into Android components. It uses Annotation Processing.
1. Butterknife
The @BindView annotation allow to inject views and performs the cast to the correct type for you. The @@OnClick(R.id.yourid) annotation allows to add OnClickListener to a view. You can optional define the method parameter of the view in case you want it injected.
Butterknife includes also findById methods which simplify code that still has to find views on a View, Activity, or Dialog. It uses generics to infer the return type and automatically performs the cast.
2. How does Butterknife work
Butterknife uses annotation processing to generated modified Java classes based on your Annotations. Annotation processing is a tool build in javac for scanning and processing annotations at compile time.
You can define custom annotations and a custom processor to handle them. These annotations are scanned and processed at compile time. The annotation processor does not change the exiting input class but it generates a new Java class. This generated Java code is compiled again as a regular Java class.
The Butterknife annotation processor scans all Java classes looking for the Butterknife annotations. If a class contains these annotations, it generates a new class based on the
Official Link
http://jakewharton.github.io/butterknife/
Other example which provide Butterknife:
https://www.journaldev.com/10439/android-butterknife-example
https://code.tutsplus.com/tutorials/quick-tip-using-butter-knife-to-inject-views-on-android–cms-23542
2. RemoveButterKnife plugin
ButterKnife is a wellknow open source tool to help you inject your view, but some times, you use plugin to gen butterknife’s code, but you don’t want to use it again.
It’s a very horrible job to delete every line inject code and write findviewbyid code, so, you can refer below plugin.
https://github.com/u3shadow/RemoveButterKnife?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=3750
This lib is quite simple for removing Butterknife if user face any problem.
Writtern by : Bilal Ansari
The post Butterknife appeared first on Youngbrainz Infotech.
This post first appeared on What Is Cloud Based Service And Which Cloud Service Is Best?, please read the originial post: here