Efficiently using position to control actions
- by John Ashmore
I want to use position (returned from a gridview for e.g.) or a similar numeric integer to do various things, e.g. create a sprite, or in any command that wants something other than a number, e.g. I want to use something like:
sprites.add(createSprite(R.drawable.image(position));
, where createSprite creates a sprite using the image supplied,
instead of:
if (position == 1) {sprites.add(createSprite(R.drawable.image1);}
if (position == 2) {sprites.add(createSprite(R.drawable.image2);}
...etc
There is an easy solution for strings:
Most efficient method to use position to open a .java
but what about for situations like this one?