Created
July 14, 2015 02:22
-
-
Save aliang228/3539aa4c0e8e38ee6888 to your computer and use it in GitHub Desktop.
Android get res id not by R
This file contains hidden or 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
import android.content.Context; | |
import android.content.res.Resources; | |
public class MResource { | |
private static int getResID(Context context, String resName, String defType) { | |
Resources res = context.getResources(); | |
return res.getIdentifier(resName, defType, context.getPackageName()); | |
} | |
public static int getIdByName(Context context, String className, String name) | |
{ | |
return getResID(context,name,className); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment