Efficiently using position to control actions
Posted
by
John Ashmore
on Stack Overflow
See other posts from Stack Overflow
or by John Ashmore
Published on 2012-06-04T04:15:58Z
Indexed on
2012/06/04
4:40 UTC
Read the original article
Hit count: 199
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?
© Stack Overflow or respective owner