Accessing Items of a Gridview
<p>I want to change Images in a gridView on a shake event, this is my code</p>

<pre><code>/* Inside a sensorChangeListener */
Drawable [] layers = new Drawable[2]; 
LayerDrawable layerDrawable;
//get the View array 
View[]array = adapter.
if (shakeEventDetected){
     /* Here I can now get the desired view via the View Array */
     /*--------------------------------------------------------*/
     int position = (int)Math.floor(Math.random());
     ImageView imgView = viewArray[position]
     layers[0] = bottomImage; 
     layers[1] = topImage;
     layerDrawable = new LayerDrawable(layers);
     //Assign image
     imgView.setImageDrawable(layerDrawable)
}
</code></pre>

<p>This is my Adapter</p>

<pre><code>package com.bachelornativ;

//imports

/* An Array that holds all the (49)views in it */
View[]array = new View[49]


// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    System.out.println("getView invoked!"+ parent);
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        //imageView.setLayoutParams(new GridView.LayoutParams(45, 45));
        //imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setPadding(4, 0,4,0);
    } else {
        imageView = (ImageView) convertView;
    }
    imageView.setImageResource(mThumbIds[position]);

    if (isChoosen){
        imageView.setImageResource(cross);
    }
/* When the views are created, I fill the view array with the references, I also write a getter for it*/
    viewArray[position] = imageView;    
    return imageView;
}
</code></pre>

<p>}</p>

<p>I want to know how to access the desired Image in my adapter.
I did it before on my code and it worked, but in an onItemClicklistener. It passes in a view, so I could refer to this View. In my ShakeeventListener, I cant refer to a view. So how can I access the view? </p>

<p>I'm googling for hours now, cant find a solution. Any help is greatly appreciated.</p>

<p>Thank you.</p>
