If you look inside your generated R.drawable object you will see that the IDs are contiguous, in my case (and probably yours) beginning at 0x7f020000. As they seem to be sorted by alpha you could probably add dummy images AAAAAAA.png and ZZZZZZ.png and iterate between the two IDs exclusively.
I can't endorse your reasons for attempting this, but I reckon that would work.