您的位置:首页 > 移动开发 > Android开发

android 动态获取ID通过Resources的 getIdentifier 方法

2013-04-12 21:47 330 查看

public int getIdentifier
(String name,
String defType,
String defPackage)

Added in
API level 1

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.

Parameters
nameThe name of the desired resource.
defTypeOptional default resource type to find, if "type/" is not included in the name. Can be null to require an explicit type.
defPackageOptional 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.)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: