In the previous development of Android, I used 2.2 Application Development. I put some small icon files in one of the three directories drawable-hdpi, drawable-ldpi, and drawable-mdpi. Code Directly reference R. drawable. ** this method is OK.
However, when I was working on an android project in the company yesterday (with a minimum of 1.5 APIs supported, but developed under 2.3.3), this problem occurred. During code check, it is true that apart from R. drawable. pic1, but when the application runs on a virtual device, the system reports an error and cannot find the resource file. Then, the system notifies you of the resource file ID. after reading this, the ID corresponds to the pic1 image. this image is stored in R. in drawable-hdpi. so I am very depressed. What is this picture clearly?
Later, a colleague familiar with Android came to tell me that android1.5 was used to find the image resources in the drawable folder, android 2.2 contains three folders that cannot be accurately identified in Android 1.5.
Back in the evening, I checked the relevant information online and found a problem similar to mine. Article :
-------------------------------------------------------------------
The directory structure of android1.6 cannot find the res resource.
Http://7090.iteye.com/blog/997482
The target = Android-3 APK is packaged as 1.5. When running on the 1.5 simulator, an error is reported, files under Res cannot be found.
Java code
Android. content. res. resources $ notfoundexception
Later, the simulator of 1.6 can run normally. It seems that it is still backward compatible, and the r of the simulator of 1.5. the Java file is still the content in the drawable folder. More than 1.6 will find the appropriate resource file based on the screen size.
-------------------------------------------------------------------
It seems that when developing Android applications, if you want to take into account the old version of Android, you need to create a drawable folder separately.