[英]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. 我有一个FAB类,它扩展了FrameLayout,在这里我想有一个实现揭示效果的hide方法。 Therefore I need to set the visibility to INVISIBLE: 因此,我需要将可见性设置为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)'". 但是,当尝试在'this'上调用setVisibility()
时出现错误:“无法解析方法'setVisibilty(int)'”。
Seems that this.setVisibility(View.INVISIBLE);
似乎this.setVisibility(View.INVISIBLE);
is located inside another class. 位于另一个类内。 It this case FloatingActionButton.this.setVisibility(View.INVISIBLE)
will solve your issue. 这种情况下, FloatingActionButton.this.setVisibility(View.INVISIBLE)
将解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.