Butter Knife 是一个专注于 Android 系统 View 的注入框架,
让你从烦人的 findViewById 中解脱出来。同时还支持 View 的一些事件处理函数。
butterknife地址:https://github.com/JakeWharton/butterknife
以下介绍两种实现button的方法
老版本方法(InjectView)
在app目录下的build.gradle中添加如下依赖
dependencies {
compile 'com.jakewharton:butterknife:6.0.0'
}
在activity中添加按键
public class SimpleActivity extends Activity {
@InjectView(R.id.hello)
Button hello;