다음을 통해 공유


Resources.GetIdentifier(String, String, String) Method

Definition

Return a resource identifier for the given resource name.

[Android.Runtime.Register("getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", "GetGetIdentifier_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler")]
public virtual int GetIdentifier (string? name, string? defType, string? defPackage);
[<Android.Runtime.Register("getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", "GetGetIdentifier_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member GetIdentifier : string * string * string -> int
override this.GetIdentifier : string * string * string -> int

Parameters

name
String

The name of the desired resource.

defType
String

Optional default resource type to find, if "type/" is not included in the name. Can be null to require an explicit type.

defPackage
String

Optional default package to find, if "package:" is not included in the name. Can be null to require an explicit package.

Returns

int The associated resource identifier. Returns 0 if no such resource was found. (0 is not a valid resource ID.)

Attributes

Remarks

Return a resource identifier for the given resource name. A fully qualified resource name is of the form "package:type/entry". The first two components (package and type) are optional if defType and defPackage, respectively, are specified here.

Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.

Java documentation for android.content.res.Resources.getIdentifier(java.lang.String, java.lang.String, java.lang.String).

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.

Applies to