Aracılığıyla paylaş


Resources Class

Definition

Class for accessing an application's resources.

[Android.Runtime.Register("android/content/res/Resources", DoNotGenerateAcw=true)]
public class Resources : Java.Lang.Object
[<Android.Runtime.Register("android/content/res/Resources", DoNotGenerateAcw=true)>]
type Resources = class
    inherit Object
Inheritance
Resources
Derived
Attributes

Remarks

Class for accessing an application's resources. This sits on top of the asset manager of the application (accessible through #getAssets) and provides a high-level API for getting typed data from the assets.

The Android resource system keeps track of all non-code assets associated with an application. You can use this class to access your application's resources. You can generally acquire the android.content.res.Resources instance associated with your application with android.content.Context#getResources getResources().

The Android SDK tools compile your application's resources into the application binary at build time. To use a resource, you must install it correctly in the source tree (inside your project's res/ directory) and build your application. As part of the build process, the SDK tools generate symbols for each resource, which you can use in your application code to access the resources.

Using application resources makes it easy to update various characteristics of your application without modifying code, and&mdash;by providing sets of alternative resources&mdash;enables you to optimize your application for a variety of device configurations (such as for different languages and screen sizes). This is an important aspect of developing Android applications that are compatible on different types of devices.

After Build.VERSION_CODES#R, Resources must be obtained by android.app.Activity or android.content.Context created with android.content.Context#createWindowContext(int, Bundle). Application#getResources() may report wrong values in multi-window or on secondary displays.

For more information about using resources, see the documentation about Application Resources.

Java documentation for android.content.res.Resources.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Resources(AssetManager, DisplayMetrics, Configuration)

Create a new Resources object on top of an existing set of assets in an AssetManager.

Resources(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

IdNull

The null resource ID.

Properties

Assets

Retrieve underlying AssetManager storage for these resources.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Configuration

Return the current configuration that is in effect for this resource object.

DisplayMetrics

Returns the current display metrics that are in effect for this resource object.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
System

Return a global shared Resources object that provides access to only system resources (no application resources), is not configured for the current screen (can not use dimension units, does not change based on orientation, etc), and is not affected by Runtime Resource Overlay.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddLoaders(ResourcesLoader[])

Adds a loader to the list of loaders.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
FinishPreloading()

Called by zygote when it is done preloading resources, to change back to normal Resources operation.

FlushLayoutCache()

Call this to remove all cached loaded layout resources from the Resources object.

GetAnimation(Int32)

Return an XmlResourceParser through which you can read an animation description for the given resource ID.

GetAttributeSetSourceResId(IAttributeSet)

Returns the resource ID of the resource that was used to create this AttributeSet.

GetBoolean(Int32)

Return a boolean associated with a particular resource ID.

GetColor(Int32, Resources+Theme)

Returns a color integer associated with a particular resource ID.

GetColor(Int32)

Returns a color integer associated with a particular resource ID.

GetColorStateList(Int32, Resources+Theme)

Returns a color state list associated with a particular resource ID.

GetColorStateList(Int32)

Returns a color state list associated with a particular resource ID.

GetDimension(Int32)

Retrieve a dimensional for a particular resource ID.

GetDimensionPixelOffset(Int32)

Retrieve a dimensional for a particular resource ID for use as an offset in raw pixels.

GetDimensionPixelSize(Int32)

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

GetDrawable(Int32, Resources+Theme)

Return a drawable object associated with a particular resource ID.

GetDrawable(Int32)

Return a drawable object associated with a particular resource ID.

GetDrawableForDensity(Int32, Int32, Resources+Theme)

Return a drawable object associated with a particular resource ID for the given screen density in DPI.

GetDrawableForDensity(Int32, Int32)

Return a drawable object associated with a particular resource ID for the given screen density in DPI.

GetFloat(Int32)

Retrieve a floating-point value for a particular resource ID.

GetFont(Int32)

Return the Typeface value associated with a particular resource ID.

GetFraction(Int32, Int32, Int32)

Retrieve a fractional unit for a particular resource ID.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetIdentifier(String, String, String)

Return a resource identifier for the given resource name.

GetIntArray(Int32)

Return the int array associated with a particular resource ID.

GetInteger(Int32)

Return an integer associated with a particular resource ID.

GetLayout(Int32)

Return an XmlResourceParser through which you can read a view layout description for the given resource ID.

GetMovie(Int32)

Return a movie object associated with the particular resource ID.

GetQuantityString(Int32, Int32, Object[])

Returns the string necessary for grammatically correct pluralization of the given resource ID for the given quantity.

GetQuantityString(Int32, Int32)

Returns the string necessary for grammatically correct pluralization of the given resource ID for the given quantity.

GetQuantityText(Int32, Int32)

Returns the character sequence necessary for grammatically correct pluralization of the given resource ID for the given quantity.

GetQuantityTextFormatted(Int32, Int32)

Returns the character sequence necessary for grammatically correct pluralization of the given resource ID for the given quantity.

GetResourceEntryName(Int32)

Return the entry name for a given resource identifier.

GetResourceName(Int32)

Return the full name for a given resource identifier.

GetResourcePackageName(Int32)

Return the package name for a given resource identifier.

GetResourceTypeName(Int32)

Return the type name for a given resource identifier.

GetString(Int32, Object[])
GetString(Int32)

Return the string value associated with a particular resource ID.

GetStringArray(Int32)

Return the string array associated with a particular resource ID.

GetText(Int32, String)

Return the string value associated with a particular resource ID.

GetText(Int32)

Return the string value associated with a particular resource ID.

GetTextArray(Int32)

Return the styled text array associated with a particular resource ID.

GetTextArrayFormatted(Int32)

Return the styled text array associated with a particular resource ID.

GetTextFormatted(Int32, ICharSequence)

Return the string value associated with a particular resource ID.

GetTextFormatted(Int32)

Return the string value associated with a particular resource ID.

GetValue(Int32, TypedValue, Boolean)

Return the raw data associated with a particular resource ID.

GetValue(String, TypedValue, Boolean)

Return the raw data associated with a particular resource ID.

GetValueForDensity(Int32, Int32, TypedValue, Boolean)

Get the raw value associated with a resource with associated density.

GetXml(Int32)

Return an XmlResourceParser through which you can read a generic XML resource for the given resource ID.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
NewTheme()

Generate a new Theme object for this set of Resources.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ObtainAttributes(IAttributeSet, Int32[])

Retrieve a set of basic attribute values from an AttributeSet, not performing styling of them using a theme and/or style resources.

ObtainTypedArray(Int32)

Return an array of heterogeneous values.

OpenRawResource(Int32, TypedValue)

Open a data stream for reading a raw resource.

OpenRawResource(Int32)

Open a data stream for reading a raw resource.

OpenRawResourceFd(Int32)

Open a file descriptor for reading a raw resource.

ParseBundleExtra(String, IAttributeSet, Bundle)

Parse a name/value pair out of an XML tag holding that data.

ParseBundleExtras(XmlReader, Bundle)

Parse a series of android.R.styleable#Extra &lt;extra&gt; tags from an XML file.

RemoveLoaders(ResourcesLoader[])

Removes loaders from the list of loaders.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
UpdateConfiguration(Configuration, DisplayMetrics)

Store the newly updated configuration.

Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to