Reputation: 1246
I'm trying to set an image from a non Activity class, the drawable name is saved in a string and comes from another methor but the problem is that getPackageName() gives me this error: "cannot resolve method 'getPackageName()'" and I have no idea what to do, here is my code:
String[] string = printArray(false, context);
image1.getResources().getIdentifier(string[0] , "drawable", getPackageName());
image2.getResources().getIdentifier(string[1] , "drawable", getPackageName());
image3.getResources().getIdentifier(string[2] , "drawable", getPackageName());
Upvotes: 0
Views: 330