Ege Kuzubasioglu
Ege Kuzubasioglu

Reputation: 6282

@OnClick on Butterknife doesn't work

There is no error in code or gradle build but when I click to button, nothing happens

@BindView(R.id.bWakeup) Button bWakeup;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);


}

@OnClick(R.id.bWakeup)
public void wakeButtonClick(View v) {
    Intent intent = new Intent(MainActivity.this, SetTimeActivity.class);
    intent.putExtra(MODE, WAKEUP);
    startActivity(intent);
}

Upvotes: 1

Views: 1419

Answers (2)

Rissmon Suresh
Rissmon Suresh

Reputation: 14053

Edited: Configuration is more simple now.

I Followed below-given step and its working fine for me.

Add the below Butter Knife dependencies:

apply plugin: 'com.android.library'

android {
          ...
        }
dependencies {
              compile 'com.jakewharton:butterknife:8.8.1'
              annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
        }

If you are using Kotlin, replace annotationProcessor with kapt.

For more refer

Upvotes: 2

Wasim K. Memon
Wasim K. Memon

Reputation: 6067

For single button you will not get view object so just remove it and check

example

@OnClick(R.id.bWakeup)
public void onClick() {}

Upvotes: 0

Related Questions