
All of these features are what you can expect from the Butter Knife library to help you keep your codebase neat and tidy. can all be mapped to a field via an annotation. Say you’ve a bunch of fields in your layout that get hidden or unhidden depending on some logic? Butter Knife lets you operate on a group of views, via a list or array, with actions or setters so instead of a loop through the fields of a field group you’re able to easily act on all of the fields with a line of code.įinally, Butter Knife helps eliminate resource lookups by using resource annotations on fields. Here’s where Butter Knife gets interesting. That’s pretty rad considering before you had to either create a find and then an anonymous inner class to handle the click on that field OR have an onClick attribute on the field in your layout and hope you created the method with the same name. Similarly, you’re able to annotate methods in your Java code to handle clicks. So one of the main benefits is no more findViewById calls.



It helps you access views contained in the layout files of your Activities or Fragments.

As an Android developer you’ve undoubtedly seen, and called, that method many times. So if you’re an Android developer than you’ve used findViewById.
