ademar111190
ademar111190

Reputation: 14505

Wrong warning in android studio

The Android studio shows the warning "method setFoo is never used" in the code bellow:

public void setFoo(float foo) {
    mFoo = foo;
    invalidate();
}

protected void startFooProcess() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(this, "foo", 1.0f, 0.0f);
    animator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    animator.setTarget(this);
    animator.start();
}

But I`m using it with object animator, How to supress this kind of warning?

Upvotes: 4

Views: 2632

Answers (2)

Jack Lee
Jack Lee

Reputation: 41

File > Invalidate caches / Restart

to fix this problem

You can see this enter link description here

Upvotes: 4

Scott Barta
Scott Barta

Reputation: 80010

If you click on the setFoo method name you'll get a yellow lightbulb icon which you can click on for quickfix icons. As a shortcut, with the caret in the method name, you can use the key combo for "Show Intention Actions", which is Alt+Enter on the default Mac keymap that I use.

The quickfix "Safe delete 'setFoo(float)'" isn't what you want, but you can expand that to see more options either via the keyboard or by clicking the right arrow. That shows you options you can use to disable the inspection. Screenshot:

Screenshot of UI for options for suppressing warnings

Upvotes: 1

Related Questions