Remove findViewById calls by using @Bind on widgets and fields.
Remove the click listeners by annotating methods with @OnClick and others.
class MainActivity extends Activity {
@Bind(R.id.user) EditText username;
@Bind(R.id.pass) EditText password;
@BindString(R.string.login_error)
String loginErrorMessage;
@OnClick(R.id.submit) void submit() {
// TODO call server...
}
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_activity);
ButterKnife.bind(this);
// TODO Use fields...
}
}
For Gradle dependency
compile 'com.jakewharton:butterknife:7.0.1'
NOTE: Don't forget to use ButterKnife.bind(this) in your Oncreate.
0 Comment(s)