Code example for GridView

Methods: getChildAt

0
						mMatrix[position] = 0 == mMatrix[position] ? 1 : 0;
 
						int pL = -1, pR = -1, pU = -1, pD = -1;
						if (0 != position % 5) {
							pL = position - 1;
							imgView = (Button) mGridView.getChildAt(pL);
 
							imgView.setBackgroundResource(getId(mMatrix[pL]));
							mMatrix[pL] = 0 == mMatrix[pL] ? 1 : 0;
						} 
						if (4 != position % 5) {
							pR = position + 1;
							imgView = (Button) mGridView.getChildAt(pR);
 
							imgView.setBackgroundResource(getId(mMatrix[pR]));
							mMatrix[pR] = 0 == mMatrix[pR] ? 1 : 0;
						} 
						if (0 != position / 5) {
							pU = position - 5;
							imgView = (Button) mGridView.getChildAt(pU);
 
							imgView.setBackgroundResource(getId(mMatrix[pU]));
							mMatrix[pU] = 0 == mMatrix[pU] ? 1 : 0;
						} 
						if (4 != position / 5) {
							pD = position + 5;
							imgView = (Button) mGridView.getChildAt(pD);
 
							imgView.setBackgroundResource(getId(mMatrix[pD]));
							mMatrix[pD] = 0 == mMatrix[pD] ? 1 : 0;
						}