I need to pass a resource ID to a method in one of my classes. It needs to use both the id that the reference points to and also it needs the string. How should I best achie
You can use this function to get resource ID.
public static int getResourceId(String pVariableName, String pResourcename, String pPackageName)
{
try {
return getResources().getIdentifier(pVariableName, pResourcename, pPackageName);
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
So if you want to get for drawable call function like this
getResourceId("myIcon", "drawable", getPackageName());
and for string you can call it like this
getResourceId("myAppName", "string", getPackageName());
Read this