Thursday, 20 March 2014

change image of imageview android

Change image of ImageView dynamically in Android; Change the image and assign the resource image dynamically;

Code Snippet:
Place the imageView in the screen like; Here you can see that SRC is used to assign the screen for Image View.

    <ImageView
        android:id="@+id/imgvAlpha"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/a" />

Change the imageView Image dynamically by;

imgvAlpha.setBackgroundResource(R.drawable.zip);
There zip present in the resourse file;


No comments:

Post a Comment