ragnonerodocet
Lurker
Hi all, my first post!
I am working on a very simple project:
Only an Activity whit a GridLayout, a 3x3 matrix.
I have also created a custom Adaptor like this:
that simply set an image on each cell.
Now I want to start with an empty grid, so I have deleted the line in which i set the image on every cell ('imgV.setImageResource(R.drawable.icon)').
Every 2 seconds, I want that a casual cell was filled with an image. Every 2 seconds the image diappears and fill another (or also the same) cell.
I have try in this way into my Activity class:
but the method getChild does not return a cell (in my case, it returns null).
How can I perform the work?
I am working on a very simple project:
Only an Activity whit a GridLayout, a 3x3 matrix.
I have also created a custom Adaptor like this:
Code:
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imgV = new ImageView(myContext);
imgV.setImageResource(R.drawable.icon);
return imgV;
}
that simply set an image on each cell.
Now I want to start with an empty grid, so I have deleted the line in which i set the image on every cell ('imgV.setImageResource(R.drawable.icon)').
Every 2 seconds, I want that a casual cell was filled with an image. Every 2 seconds the image diappears and fill another (or also the same) cell.
I have try in this way into my Activity class:
Code:
public void onCreate(Bundle savedInstanceState) {
....
GridView grV = (GridView) findViewById(R.id.gridview);
grV.setAdapter(myAd = new MyAdapter(this));
startAnimation();
}
private void startAnimation() {
GridView grV = (GridView) findViewById(R.id.gridview);
grV.getChildAt(count).setBackgroundResource(R.drawable.icon);
.....
startAnimation() //recursive!!!
}
but the method getChild does not return a cell (in my case, it returns null).
How can I perform the work?