Get a resource id with any of known resource name like string,drawable, id... Using getIdentifier 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.
Example: defType = "string" (or) "id" (or) "drawable"
idStr = if drawable like R.drawable.ic_add means then "ic_add"
Example: defType = "string" (or) "id" (or) "drawable"
idStr = if drawable like R.drawable.ic_add means then "ic_add"
public int getresId(String defType, String idStr){
int resId = this.getResources().getIdentifier(idStr, defType, this.getPackageName());
return resId;
}
0 comments:
Post a Comment