setVisibility() - Hide a TextView, in Java

How to Hide a TextView, in Java

Related XML Attribute: android:visibility

setVisibility() was added in API Level 1

1. Find the TextView by ID named myTextView.

2. In the MainActivity.java file, add the code below to the imports section.

import android.view.View;

3. In the MainActivity.java file, add the below line of code to the onCreate method.

myTextView.setVisibility(View.GONE);

4. All options:

myTextView.setVisibility(View.VISIBLE);
myTextView.setVisibility(View.INVISIBLE);
myTextView.setVisibility(View.GONE);

5. Compile and run!

Related Articles:


References:
http://developer.android.com/reference/android/view/View.html#setVisibility(int)