android - Is there a way to do this...R.Id."string"? -
i have folder called "raw" in res folder selection of short audio tracks , screen displays several buttons.
i able start mediaplayer this...
string[] track = {"track1", "track2", "track3", etc...} mplayer = mediaplayer.create(this, r.raw.track[x]);
the issue r.raw.track[x]
.
is there way in way i'm attempting or need whole new approach?
thanks in advance advice can offer.
i going assume here x
index, perhaps pulled user selection track
.
you have 2 main options:
have corresponding
int[] {r.raw.track1, r.raw.track2, ...}
,r.raw
value wayuse
getresources().getidentifier()
identifier @ runtime
the second option easier uses reflection , not super-quick. in case, should not matter, doubt looking these ids in tight loop.
Comments
Post a Comment