img=(ImageView)findViewById(R.id.imageview1);
Drawable myDrawable = getResources().getDrawable(R.drawable.imageView1);
img.setImageDrawable(myDrawable);
In XML :
android:background="@drawable/imagename
android:src="@drawable/imagename"
In Code :
imageview.setImageResource(R.drawable.imagename);