-2

here is my code:

public class MainActivity extends Activity {
    @OnClick(R.id.btn_login)
    void loginClick(){
        //
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.bind(this);
    }
}

I add butterknife in my project and it works well.But there is a 'problem' makes me confused.enter image description here

it always prompt Method is never used.actully I know the method used.I just don't wanna see this tip.Is there anyone who can help me to get rid of this tip.

PS:when I run the butterknife sample, I didn't see any tips like this.

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Freddy
  • 764
  • 2
  • 6
  • 21

2 Answers2

2

The correct way in Android Studio to suppress these warnings is to press Alt+Enter on the method giving the Method 'yourFunction()' is never used warning, and selecting

Suppress for methods annotated by 'butterknife.OnClick'

Please go through this answer for more details and more options.

Community
  • 1
  • 1
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
1

Place cursor on loginClick method and click alt+enter.

It will give suggestions and click on

Suppress for methods annotated by 'butterknife.OnClick'

Ravi Gadipudi
  • 1,446
  • 1
  • 17
  • 30