I need get a resource ID from string
String s = "R.raw.button5";
final MediaPlayer mp2 = MediaPlayer.create(this,Integer.valueOf((s));
You can use getIdentifier(....). If you have button with id "R.id.button5" then this is your code.
int id = getResources().getIdentifier("button5", "id", context.getPackageName());
final MediaPlayer mp2 = MediaPlayer.create(this,id);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With