android studio中使用方法:

1.build.gradle(Modul: app) 添加
dependencies{

compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}


2.添加插件 ButterKnife,选择 Zelezny 那个

3.activity*.java 的onCreate() 中setContentView下面添加(可以放在BaseActivity中)
  setContentView(R.layout.activity_main);
  ButterKnife.bind(this);

4.
  /** 绑定控件 相当于 TextView tv = findViewById(R.id.tv) */
  @BindView(R.id.tv)
  TextView tv;


  /** 绑定事件 */
  @OnClick(R.id.btn)
  public void onBtnClicked() {}

4.(自动生成)选中 R.layout.activity_main 快捷键 Alt+Insert

相关文章:

  • 2021-06-08
  • 2021-10-29
  • 2021-12-06
  • 2021-11-28
  • 2021-12-03
  • 2021-09-11
  • 2021-06-26
猜你喜欢
  • 2021-05-14
  • 2021-11-02
  • 2021-11-05
  • 2021-05-23
  • 2021-09-23
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案