Take the 2-minute tour ×

I am having an array of images. I need to display 3 images in a row and then the next in another row. How to do this using nested for loops. can anyone help me over this? thanks.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

The basic nested loop structure looks like this:

int imageIndex = 0;
    for (int column = 0; column < columnCount; column++ {
        // Draw your image here at x position of (column * image width)
        // and y position of (row * image height). Add a bit to each if you
        // want some spacing between your images.
        // For example:
        drawMyImage(images[imageIndex++], column * imageWidth, row * imageHeight);
share|improve this answer

Its simple, use GridView with 3 columns.


share|improve this answer

You need two loops. The outer loop is for the rows. Each element in the row corresponds with a column, so the inner loop is for the columns.

share|improve this answer

Your Answer


