Skip to content

Instantly share code, notes, and snippets.

@aliang228
Created July 14, 2015 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliang228/3539aa4c0e8e38ee6888 to your computer and use it in GitHub Desktop.
Save aliang228/3539aa4c0e8e38ee6888 to your computer and use it in GitHub Desktop.
Android get res id not by R
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