Android ButterKnife edit

Binding Listeners using ButterKnife

OnClick Listener:

@OnClick(R.id.login)
public void login(View view) {
  // Additional logic
}

All arguments to the listener method are optional:

@OnClick(R.id.login)
public void login() {
   // Additional logic
}

Specific type will be automatically casted:

@OnClick(R.id.submit)
public void sayHi(Button button) {
  button.setText("Hello!");
}

Multiple IDs in a single binding for common event handling:

@OnClick({ R.id.door1, R.id.door2, R.id.door3 })
public void pickDoor(DoorView door) {
  if (door.hasPrizeBehind()) {
    Toast.makeText(this, "You win!", LENGTH_SHORT).show();
  } else {
    Toast.makeText(this, "Try again", LENGTH_SHORT).show();
  }
}

Custom Views can bind to their own listeners by not specifying an ID:

public class CustomButton extends Button {
  @OnClick
  public void onClick() {
    // TODO 
  }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Table Of Contents
34 ButterKnife
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close