Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android display drawable in imageview

img=(ImageView)findViewById(R.id.imageview1);
Drawable myDrawable = getResources().getDrawable(R.drawable.imageView1);
img.setImageDrawable(myDrawable);
Comment

android imageview set image from drawable programmatically

In XML :
    android:background="@drawable/imagename 
    android:src="@drawable/imagename"
    
In Code :
	imageview.setImageResource(R.drawable.imagename);
Comment

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);
Comment

how to create a new imageview in android java

ImageView move = new ImageView(this);
Comment

PREVIOUS NEXT
Code Example
Java :: get random number from enum in java 
Java :: springdoc 
Java :: java declare array 
Java :: get first entry in set java 
Java :: java create file in folder 
Java :: split number java 
Java :: initial data for list java 
Java :: double.parsedouble in java 
Java :: Printing array list through for loop in java 
Java :: imageview height based on screen size 
Java :: compare two character alphabetically java 
Java :: java parseint 
Java :: Get the last day of a month in Java 
Java :: code for checking android build version 
Java :: arrays.aslist 
Java :: empty set java 
Java :: min max heap java 
Java :: java constructor chaining 
Java :: formatting an integer in java 
Java :: wrapper classes in java 
Java :: java sum of array elements 
Java :: java replace character 
Java :: int [] to Integer[] 
Java :: which api is android 12 
Java :: how to add chips dynamically android 
Java :: array arraylist java 
Java :: java print item to text file 
Java :: java collection interface 
Java :: HOW TO PARSE a string into a number in java 
Java :: java program to find the power of a number 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =