Remove "Method is never used" warning for OnClick annotation in Android Studio
Solution 1:
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'
Solution 2:
Simply add this annotation:
@SuppressWarnings("unused")
Just like that:
@SuppressWarnings("unused")
@OnClick(R.id.myButton)
public void clickHandler()
{
// ...
}
My personal preference (which I see as good practice) is to add a comment with a brief explanation:
@SuppressWarnings("unused") // it's actually used, just injected by Butter Knife