public class MainActivity extends AppCompatActivity { @BindView(R.id.text_view) TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); textView.setText("Hello ButterKnife"); } }
public class MainActivity extends AppCompatActivity { @BindView(R.id.button) Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); } @OnClick(R.id.button) public void onButtonClick() { Toast.makeText(this, "Button Clicked", Toast.LENGTH_SHORT).show(); } }
public class MainActivity extends AppCompatActivity { @BindView(R.id.text_view) TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); textView.setText("Hello ButterKnife"); } @Override protected void onPause() { super.onPause(); ButterKnife.unbind(this); } }
import butterknife.*;