Last active
July 12, 2017 13:36
-
-
Save Subtle-fox/f1d79b7bf87d0fc12f3d9c597975e23c to your computer and use it in GitHub Desktop.
Obtain resourse identifier by it's name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getResIdByName(Context appContext, String resType, String name) { | |
return appContext.getResources().getIdentifier(name, resType, appContext.getPackageName()); | |
} | |
// usage: | |
getResIdByName(appContext, "string", name); | |
getResIdByName(appContext, "drawable", name); | |
getResIdByName(appContext, "layout", name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment