SetVisibility doesn't work?

android, layout, visibility

Solution

Why are you inflating a layout here?:

View convertView = activity.getLayoutInflater().inflate(R.layout.layout_home, null);

Just do:

View v = activity.findViewById(R.id.ll_options);
v.setVisibility(View.INVISIBLE);

Problem

I'm new to developing with android. I have a grid contained in a `LinearLayout` and each item which makes up the grid is a button. I want this `LinearLayout` to be invisible when the user pushes any of these buttons. This is my 'home' layout shell: ``` <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"> <TextView/> <LinearLayout> //<-- this is the layout I want to hide <TextView/> <GridView/> </LinearLayout> </LinearLayout> ``` And this is the onClick method which I've set up in MyArrayAdapter (used to inflate buttons) ``` @Override public void onClick(View v) { View convertView = activity.getLayoutInflater().inflate(R.layout.layout_home, null); LinearLayout ll_options = (LinearLayout) convertView.findViewById(R.id.ll_options); ll_options.setVisibility(View.INVISIBLE); } ``` I think it should work but when I test it, nothing happens. I found a similar question but it doesn't solve my problem.

Original source