Android Studio Problem Solving series 2-resources in getdrawable (int) obsolete

Source: Internet
Author: User

When compiling code in Android Studio 1.2.2 today, you encounter a warning message that getdrawable (int) is obsolete in resources:

Warning: (133, Java:android.content.res.Resources) getdrawable (int) is obsolete


View [1] To summarize the following information:

There are two methods in the resources class that are deprecated in API level 22:

Obsolete interface: drawable getdrawable (int id)

Alternate interface: drawable getdrawable (int id, resources.theme Theme), and the second parameter @theme can be a null value.

or context.getdrawable (int)

Discard Reason: before Jelly_bean (i.e. Android 4.1 version), when the resource ID passed here is an alias for another drawable resource, the function does not get the final configuration density correctly. that is, the density configuration of the alias resource is different from the actual resource, and the density of the returned Drawable object will be incorrect, so scaling will be an error.

Obsolete interface: drawable getdrawablefordensity (int id, int density)

Alternate interface: drawable getdrawablefordensity (int id, int density, resources.theme Theme)


Check the getdrawable (int id) function implementation and, when invoked, output the following warning message and give the modification scheme :

Resources:

[1] Class Resources, http://developer.android.com/intl/zh-cn/reference/android/content/res/Resources.html

Android Studio Problem Solving series 2-resources in getdrawable (int) obsolete

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.