I’m trying to set a TextView to invisible via code, but it just won’t work. My XML declaration is (inside a LinearLayout):
<TextView android:text="\nVideo" android:visibility="visible"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/exhibitor_profile_videoSectionLabel"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>
My java is:
setContentView(R.layout.exhibitor_profile);
TextView vidLabel=new TextView(this);
vidLabel.findViewById(R.id.exhibitor_profile_videoSectionLabel);
vidLabel.setVisibility(View.INVISIBLE);
The ‘invisible’ call is only made under certain circumstances, but even when I move the call outside the conditionals so it’s guaranteed to call, the TextView remains visible. LogCat is stubbornly silent during all this or I’d happily post its contents.
You should not be creating a new
TextView. You’re trying to find an existing one: