Set visibility of a gridview element
<p>I have created one gridview and use custom adapter for that. I added two images inside grid view.one is image and another one looks like close button (which is the same in all grid view items). the close button is set invisible in the beginning, i have another button in my activity, what i want is : when i click this button, i want to set the close button in every element of my grid view, but for now, when click on it, nothing happens.
below is my code :</p>

<pre><code>    ImageView deleteFavorImage;
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browser);
    .....

    GridView favorGrid = (GridView) findViewById(R.id.favorGrid);
    favorGrid.setAdapter(adapter);
    .....
    View customView = findViewById(R.id.costumButton);
    customView.setOnClickListener(this);

@Override
public void onClick(View v) {

    switch(v.getId()){

    case R.id.costumButton:
        deleteFavorImage.setVisibility(View.VISIBLE);
    break;
    .....
    }
</code></pre>

<p>This is my image adaptor code:</p>

<pre><code>           @Override
       public View getView( int position, View convertView, ViewGroup parent)
       {

           View MyView = convertView;
           final int pos=position;

           LayoutInflater li = (LayoutInflater) MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           MyView = li.inflate(R.layout.favor_item, null);


           ImageView iv = (ImageView) MyView.findViewById(R.id.favor_item_image);
           iv.setImageResource(favorSites.get(pos));

           deleteFavorImage = (ImageView) MyView.findViewById(R.id.favDelete);
           deleteFavorImage.setImageResource(R.drawable.dubtndelete);

           return MyView;
       }
</code></pre>

<p>And finally this is my XML file code:</p>

<pre><code>           &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="85dp"
android:layout_height="85dp"
android:orientation="vertical"
android:background="@drawable/dufavframe" &gt;

    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="75dp"
    android:layout_height="75dp"
    android:orientation="vertical"
    android:layout_centerInParent="true"
    android:gravity="center"&gt;

    &lt;com.test.favorsites.AspectRatioImageView android:layout_centerHorizontal="true"
        android:id="@+id/favor_item_image"
        android:layout_alignParentTop="true" android:layout_height="wrap_content"
        android:layout_width="match_parent" android:adjustViewBounds="true"/&gt;
    &lt;/LinearLayout&gt;


    &lt;ImageView android:id="@+id/favDelete" android:visibility="invisible"
    android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="-3dp" 
    android:layout_alignParentRight="true" android:layout_marginRight="-5dp"&gt;
    &lt;/ImageView&gt;



    &lt;/RelativeLayout&gt;
</code></pre>
