Dynamic android picture gallery

I am learning Android, and I want to create simple application with few buttons on main page, each leading to small gallery. I created such application, but pictures are statically linked. What would be the best way to make it dynamically load as much as pictures as there are in res/drawable folder ? I need simplest possible method for that. Here is my code:

If I understand correctly you want to load images dynamically, without knowing their IDs or their names? I don't think there is an easy way to do it, since no-one can put images in the drawable but you. So you know before hand how many images are there and you also know their names. If you don't want to load them one by one you can put their IDs in an array or list and load them in a loop.