I am trying to make a textView invisible when pressing a button. But, if the textView is already invisible I want it to become visible.
Currently I am trying sonething like this:
public void ShowAndHide(View view){
if(textView == View.VISIBLE){
textView.setVisibility(View.INVISIBLE);
}
else {
textView.setVisibility(View.VISIBLE);
}
}
Where "textView" is a TextView which I have defined by id:
TextView textView;
textView = (TextView) findViewById(R.id.showMe_txt);
Anyone who knows why this does not work? Coming from a C# background and this is my first dabble with Java so quite unfamiliar.
CodePudding user response:
The condition should be if(textView.getVisibility() == View.VISIBLE){
CodePudding user response:
I cannot seem to upvote your comment just yet (this is literally my first post), however this did solve my problem. Thank you!