android - How to get resource id from String in Andriod -
this question has answer here:
i need resource id
string
string s = "r.raw.button5"; final mediaplayer mp2 = mediaplayer.create(this,integer.valueof((s));
you can use getidentifier(....). if have button id "r.id.button5" code.
int id = getresources().getidentifier("button5", "id", context.getpackagename()); final mediaplayer mp2 = mediaplayer.create(this,id);
Comments
Post a Comment