public class MainActivity extends AppCompatActivity {
@LzfBindView(R.id.myText)
TextView myTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LzfViewBinder.bind(this);
//一定要在setContentView之后注册 or findViewById失败
myTextView.setText("测试");
}
@Override
protected void onDestroy() {
super.onDestroy();
LzfViewBinder.unBind(this);
}
}
根目录的gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
主module的gradle
顶部添加
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile project(':annotation')//定义注解
compile project(':api')//定义操作
apt project(':apt')//定义生成代码
}