SnafuBernd
SnafuBernd

Reputation: 271

How to setVisibility within class extending FrameLayout?

I have a FAB class extending FrameLayout where I want to have a hide method which implements the reveal effect. Therefore I need to set the visibility to INVISIBLE:

public class FloatingActionButton extends FrameLayout implements Checkable {
    ...
    private void hide() {
        ...
            this.setVisibility(View.INVISIBLE);
        ...
        hideFabAnimator.start();
    }
}

But I get an error when trying to call setVisibility() on 'this' : "Cannot resolve method 'setVisibilty(int)'".

Upvotes: 0

Views: 290

Answers (1)

Sergey Glotov
Sergey Glotov

Reputation: 20346

Seems that this.setVisibility(View.INVISIBLE); is located inside another class. It this case FloatingActionButton.this.setVisibility(View.INVISIBLE) will solve your issue.

You can find explanation here.

Upvotes: 2

Related Questions