Question about resource images not found when developing compatible android 1.5 Projects

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.