How to change visibility of layout programmatically

Viewed 185249

There is a way to change the visibility of View in the XML, but how can I change programmatically visibility of the layout defined in XML? How to get the layout object?

<LinearLayout
    android:id="@+id/contacts_type"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:visibility="gone">
</LinearLayout>
5 Answers

this is a programatical approach:

 view.setVisibility(View.GONE); //For GONE
 view.setVisibility(View.INVISIBLE); //For INVISIBLE
 view.setVisibility(View.VISIBLE); //For VISIBLE
Related