Android butterKnife library tutorial with easy explanation.

In this tutorial,we will learn about the android butterknife and its uses.

Introduction of butterknife

Android butterknife is a lightweight library.

It is a view binding tools which uses the annotation processing to generate boilerplate code for us.

It removes the findViewById( and uses the @BindView(

Android  butterknife dependency

To use the butterknife in our project we need to add the below code into the build.gradle file.

implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

Android butterknife Bind

Before using view in android,first we need to bind butterknife on the onCreate( ) in the case of Activity.


In the case of fragment,within the onCreateView( ) method.

LayoutInflater inflater;
View view=inflater.inflate(R.layout.fragment,null);

Android butterknife example

In case of Activity
Public class MainActivity extends Activity
@BindView( TextView textview;
@BindView( Button button;

Public void onCreate(Bundle SavedInstanceState)
textview.setText(“Android butterknife activity example”);

Void submit()
//Here we can submit the information  on the button click.


In case of fragment

In a fragment,butterknife is same as activity.
Only need to change

ButterKnife(this,view) on  the onCreateView( ) method.

For more information about Butterknife library visit:


Hello Friends,I have written and developed this website because you can learn technology easily ,prepare for the placement and also for the any type of examination . By :Suman Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *