@BindView(R.id.my_text_view) TextView textView; @BindView(R.id.my_button) Button button; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_activity_layout); ButterKnife.bind(this); }
@OnClick(R.id.my_button) public void onButtonClicked() { // Do something when button is clicked }
@BindViews({ R.id.my_text_view_1, R.id.my_text_view_2, R.id.my_text_view_3 }) ListIn this example, `@BindViews` is used to bind multiple text views to a List. The List can then be iterated through to perform operations on each view. (These examples are from androidtutorialpoint.com) Package Library: com.jakewharton:butterknife.textViews; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_activity_layout); ButterKnife.bind(this); for (TextView textView : textViews) { // Do something with each text view } }