Recently working on an Android player project, you want to use Android's internal resources by default, such as:
Com.android.internal.r.layout.media_controller
However, direct use will report a compilation error:
com.android . internal . r does not exist
You cannot import the internal Android class, as the internal. R class isn ' t visible.
However, it can be accessed in other ways, as follows:
int mediacontrollerid = Resources.getsystem (). Getidentifier ("Media_controller", "Layout", "Android"); View layout = ((layoutinflater) Mcontext.getsystemservice (Context.layout_inflater_service)). Inflate ( Mediacontrollerid, this);
Similarly, you can access:
Mprevbutton = (ImageButton) Layout.findviewbyid (Resources.getsystem (). Getidentifier ("prev", "id", "Android")); Mprogress = (ProgressBar) Layout.findviewbyid (Resources.getsystem (). Getidentifier ("Mediacontroller_progress", "id" , "Android")), Mpausebutton = (ImageButton) Layout.findviewbyid (Resources.getsystem (). Getidentifier ("pause", "id", " Android "));
The getidentifier is used as follows, which returns the ID of the name corresponding to the
Resources.getsystem (). Getidentifier (name, Deftype, Defpackage)
And how did the above Name/deftype/defpackage get? can obtain the corresponding information from the source code http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/ Android/widget/mediacontroller.java
How to access the resource of COM.ANDROID.INTERNAL.R