We can covert String name to Resource intvalue using the below method.
int resId = getResources().getIdentifier(“<package_name>:<resource_folder>/resource_name”, null,null);
exp: int imageResId = getResources().getIdentifier(“com.example1:drawable/myimage”, null,null);
<view>.setBackgroundResource(imageResId);
No comments:
Post a Comment