How do I pass a visibility parameter and then set it?
Ex:
private void _setVisibility(View.VISIBLE a){
_viewLineStatus.setVisibility(a);
}
How do I pass a visibility parameter and then set it?
Ex:
private void _setVisibility(View.VISIBLE a){
_viewLineStatus.setVisibility(a);
}
The method parameter setVisibility
of class View
, is int
. and has the following possible values:
View.VISIBLE = 0x00000000
View.INVISIBLE = 0x00000004
View.GONE = 0x00000008
In your method, just have the signature accept a int
, like this:
private void _setVisibility(int visibility) {
_viewLineStatus.setVisibility(visibility);
}
If you want, you can even make a treatment to not set an invalid value, since the View
class does not treat:
private void _setVisibility(int visibility) {
if(visibility != View.VISIBLE && visibility != View.INVISIBLE && visibility != View.GONE) {
throw new RuntimeException("Deve passar um desses valores: View.VISIBLE, View.INVISIBLE ou View.GONE");
}
_viewLineStatus.setVisibility(visibility);
}