Android Guides | Samples

Android.Content.Res.Resources Class

Class for accessing an application's resources.

See Also: Resources

Syntax

[Android.Runtime.Register("android/content/res/Resources", DoNotGenerateAcw=true)]
public class Resources : Object

Remarks

Class for accessing an application's resources. This sits on top of the asset manager of the application (accessible through Resources.Assets) 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 Resources instance associated with your application with Context.Resources.

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—by providing sets of alternative resources—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.

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

[Android Documentation]

Requirements

Namespace: Android.Content.Res
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Content.Res.Resources are listed below.

See Also: Object

Public Constructors

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

Protected Constructors

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

Public Properties

[read-only]
AssetsAssetManager. Retrieve underlying AssetManager storage for these resources.
[read-only]
ConfigurationConfiguration. Return the current configuration that is in effect for this resource object.
[read-only]
DisplayMetricsDisplayMetrics. Return the current display metrics that are in effect for this resource object.
[read-only]
static
SystemResources. Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

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) : XmlReader
Return an XmlResourceParser through which you can read an animation description for the given resource ID.
GetBoolean(Int32) : Boolean
Return a boolean associated with a particular resource ID.
GetColor(Int32) : Color
Returns a color integer associated with a particular resource ID.
GetColorStateList(Int32) : ColorStateList
Returns a color state list associated with a particular resource ID.
GetDimension(Int32) : Single
Retrieve a dimensional for a particular resource ID.
GetDimensionPixelOffset(Int32) : Int32
Retrieve a dimensional for a particular resource ID for use as an offset in raw pixels.
GetDimensionPixelSize(Int32) : Int32
Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.
GetDrawable(Int32) : Drawable
Return a drawable object associated with a particular resource ID.
GetDrawable(Int32, Resources+Theme) : Drawable
Return a drawable object associated with a particular resource ID and styled for the specified theme.
GetDrawableForDensity(Int32, Int32) : Drawable
Return a drawable object associated with a particular resource ID for the given screen density in DPI.
GetDrawableForDensity(Int32, Int32, Resources+Theme) : Drawable
Return a drawable object associated with a particular resource ID for the given screen density in DPI and styled for the specified theme.
GetFraction(Int32, Int32, Int32) : Single
Retrieve a fractional unit for a particular resource ID.
GetIdentifier(String, String, String) : Int32
Return a resource identifier for the given resource name.
GetIntArray(Int32) : Int32[]
Return the int array associated with a particular resource ID.
GetInteger(Int32) : Int32
Return an integer associated with a particular resource ID.
GetLayout(Int32) : XmlReader
Return an XmlResourceParser through which you can read a view layout description for the given resource ID.
GetMovie(Int32) : Movie
Return a movie object associated with the particular resource ID.
GetQuantityString(Int32, Int32) : String
Returns the string necessary for grammatically correct pluralization of the given resource ID for the given quantity.
GetQuantityString(Int32, Int32, params Object[]) : String
GetQuantityText(Int32, Int32) : String
GetQuantityTextFormatted(Int32, Int32) : ICharSequence
Returns the character sequence necessary for grammatically correct pluralization of the given resource ID for the given quantity.
GetResourceEntryName(Int32) : String
Return the entry name for a given resource identifier.
GetResourceName(Int32) : String
Return the full name for a given resource identifier.
GetResourcePackageName(Int32) : String
Return the package name for a given resource identifier.
GetResourceTypeName(Int32) : String
Return the type name for a given resource identifier.
GetString(Int32) : String
Return the string value associated with a particular resource ID.
GetString(Int32, params Object[]) : String
GetStringArray(Int32) : String[]
Return the string array associated with a particular resource ID.
GetText(Int32) : String
GetText(Int32, String) : String
GetTextArray(Int32) : String[]
GetTextArrayFormatted(Int32) : ICharSequence[]
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, ICharSequence) : ICharSequence
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) : XmlReader
Return an XmlResourceParser through which you can read a generic XML resource for the given resource ID.
NewTheme() : Resources+Theme
Generate a new Theme object for this set of Resources.
ObtainAttributes(IAttributeSet, Int32[]) : TypedArray
Retrieve a set of basic attribute values from an AttributeSet, not performing styling of them using a theme and/or style resources.
ObtainTypedArray(Int32) : TypedArray
Return an array of heterogeneous values.
OpenRawResource(Int32) : Stream
Open a data stream for reading a raw resource.
OpenRawResource(Int32, TypedValue) : Stream
Open a data stream for reading a raw resource.
OpenRawResourceFd(Int32) : AssetFileDescriptor
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 NoType:android/R$styleable;Href=../../../../reference/android/R.styleable.html#Extra tags from an XML file.
UpdateConfiguration(Configuration, DisplayMetrics)
Store the newly updated configuration.