views:

98

answers:

1

sorry for asking this question again but i didnt get much help on the last one (maybe due to the holidays or because my question was a bit confusing). im trying to load images from the "drawable folder" into a gridview. unlike the "hello android gridview" tutorial i dont know the name of the images being loaded into the gridview (as the images will be added by the user at runtime). so, this array:

private Integer[] mThumbIds = {
    R.drawable.sample_2, R.drawable.sample_3,
    R.drawable.sample_4, R.drawable.sample_5,
    R.drawable.sample_6, R.drawable.sample_7,
    R.drawable.sample_0, R.drawable.sample_1,
    R.drawable.sample_2, R.drawable.sample_3,
    R.drawable.sample_4, R.drawable.sample_5,
    R.drawable.sample_6, R.drawable.sample_7,
    R.drawable.sample_0, R.drawable.sample_1,
    R.drawable.sample_2, R.drawable.sample_3,
    R.drawable.sample_4, R.drawable.sample_5,
    R.drawable.sample_6, R.drawable.sample_7

};

wont work, as i wont know the name of the images. im guessing ill need to use a for...each statement but im lost after that. thanks again for the help. happy holidays

jason

+1  A: 

You need to write a custom adapter that will load the images into the views that become the grid cells. Check out this tutorial:

http://developerlife.com/tutorials/?p=327

It uses a list view, but the concepts are the same.

CaseyB