@BindView(R.id.textview) TextView textView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); ButterKnife.bind(this); textView.setText("Hello, ButterKnife!"); }
@OnClick(R.id.button) public void onButtonClick() { // Do something when the button is clicked }
@BindView({R.id.textview1, R.id.textview2, R.id.textview3}) ListOverall, ButterKnife provides an efficient and convenient way to work with views and bindings in Android applications.textViews; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); ButterKnife.bind(this); for (TextView textView : textViews) { textView.setText("Hello, ButterKnife!"); } }