Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to set drawable name to imageview programmatically

String uri = "@drawable/myresource";  // where myresource (without the extension) is the file

int imageResource = getResources().getIdentifier(uri, null, getPackageName());

imageview= (ImageView)findViewById(R.id.imageView);
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable(res);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #set #drawable #imageview #programmatically
ADD COMMENT
Topic
Name
2+2 =