How Android references resource project requirements under the COM.ANDROID.INTERNAL.R directory
One resource is the same as a resource on the system, and you want to reference it: Frameworks/base/core/res/res/drawable/ic_text_dot.xml
File name: Ic_text_dot.xml
Specific content of the document:
<?xml version= "1.0" encoding= "Utf-8"?><!--Copyright (C) The Android Open Source Project Licensed under The Apache License, Version 2.0 (the "License"); You are not a use of this file except in compliance with the License. Obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 unless required by Applica BLE law or agreed-in-writing, software distributed under the License is distributed on a "as is" BASIS, Withou T warranties or CONDITIONS of any KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><inset xmln S:android= "Http://schemas.android.com/apk/res/android" android:inset= "10DP" > <shape android:shape= "Oval" > <solid android:color= "? android:attr/textcolorsecondary"/> <size android:width= "4DP" android:h eight= "4DP"/> </shape></inset>
The resource's reference in the code is: Com.android.internal.r.drawable.ic_text_dot encountered problems
But I do not know why, when I use Java code in the project to invoke this resource, has been prompted to fail, unable to find the target:
ImageView ImageView = (ImageView) Findviewbyid (r.id.img); Imageview.setimagedrawable (Getdrawable (Com.android.internal.r.drawable.ic_text_dot)); COM.ANDROID.INTERNAL.R cannot is resolved to a variable
Why the problem occurred
You cannot access ID ' s of COM.ANDROID.INTERNAL.R at compile time, but can access the defined internal resources at run Time and get the resource by name.
The solution is to:
ImageView ImageView = (ImageView) Findviewbyid (r.id.img); Imageview.setimageresource (Resources.getsystem (). Getidentifier ("Ic_text_dot", "drawable", "Android"));
Reference: http://stackoverflow.com/questions/3486819/ How-to-resolve-the-error-com-android-internal-r-cannot-be-resolved-when-i-usin
How Android references resources under the COM.ANDROID.INTERNAL.R directory