配置
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'android-apt'
dependencies {
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
}
基本用法
@BindView(R.id.tv_hello)
TextView mTvHello;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentView());
ButterKnife.bind(this); //要在setContentView后调用
}
@OnClick(R.id.tv_hello)
public void onClick(){
Toast.makeText(this, "hello ---- 1", Toast.LENGTH_SHORT).show();
}
Zelezny插件的使用
- Settings -> Plugins
- 搜索Zelezny
- Click Browse to search for non-bundled plugins
- Install -> Restart
- 右键layout使用