Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, January 23, 2016

Can't access drawable resource from menu for navigation drawer

Can't access drawable resource from menu for navigation drawer


Am trying to add icons to a navigation drawer but somehow, I can't access resources in the res/drawable folder.

This is the list of icons I have in my drawable-hdpi folder:

enter image description here

But I can't access any of them using the correct method:

enter image description here

It says cannot resolve the symbol '@drawable/ic_action_user'

This is strange because I have another application open that uses the exact same method and it works fine there.I've tried invalidating cache and restarting Android Studio with no luck.

All I get are the icons in the drawable-v21 folder:

enter image description here

enter image description here

Answer by S Sathiya for Can't access drawable resource from menu for navigation drawer


First check that the icons is available in your resources folder.

Answer by nick_kryloff for Can't access drawable resource from menu for navigation drawer


Try to use gradle task 'clean' and rebuild project

Answer by Ahmed Elgendy for Can't access drawable resource from menu for navigation drawer


Try to put your images in the main drawable directory (res/drawable).. Not in the sub one (res/drawable-hdpi)

Answer by deepakjohn141 for Can't access drawable resource from menu for navigation drawer


you might have set min sdk version to 21 in gradle, set it to below version or copy all drawables in drawables-hdpi to drawables-v21, as only drawables in drawables-v21 will be used in versions equal to and above 21

Answer by boyapati for Can't access drawable resource from menu for navigation drawer


You have created drawable-hdpi folder inside drawable.
You should move it to res folder .

Answer by IntelliJ Amiya for Can't access drawable resource from menu for navigation drawer


You need to put images in drawable folder instead of drawable-v21. Create below drawable folder under res .

drawable-ldpi

drawable-mdpi

drawable-hdpi

drawable-xhdpi

drawable-xxhdpi

Then Clean & Rebuild your Project . Hope this helps .

You can check #SO How to import set of icons into Android Studio project


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.