In my code, I have an ArrayList<Buttons> field named mButtons . Each of these buttons calls (in XML) the same onClick function onButtonClick . The function is as follows:
public void onButtonClick(View view) { int buttonIndex = mButtons.indexOf(view); }
But Android Studio warns me about Suspicious call to 'ArrayList.indexOf' .
Ok, I tried to get rid of it by clicking view on Button . Then the warning changed to Casting 'view' to 'Button' is redundant .
Well, I tried to change the function signature to get Button instead of view . But now I have one warning for each Button (XML) declaration: Method 'onButtonClick' on '...Activity' has incorrect signature .
I'm really considering adding //noinspection SuspiciousMethodCalls , since there seems to be no workaround for this.
I would appreciate it if anyone knows how to get rid of it.
source share