In my android 2.2 app, I've added my image to the res/drawable-mdpi folder. However, I cannot seem to access it using R.drawable.. As far as I know, there isn't any additional configuration I need to do - any help?
To import image resources into your project, do the following: Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import.
I figured this out. The issue was that the project was importing android.R instead of using the generated R file - if you encounter this problem, check your imports to make sure the correct package/file is being imported.
You need to use a fully qualified name when importing the generated R file. Check your import statements.
Take the following package statement:
package me.rhys.example;
Then the generated R file can be imported using:
import me.rhys.example.R;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With