Set Image resource for ImageView
package app.test; import android.app.Activity; import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; import android.widget.ImageView; public class Test extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView imgView = (ImageView)findViewById(R.id.image3); imgView.setImageResource( R.drawable.icon ); } } //main.xml <?xml version="1.0" encoding="utf-8"?> <!-- This file is at /res/layout/list.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="fill_parent"> <ImageView android:id="@+id/image1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" /> <ImageView android:id="@+id/image2" android:layout_width="125dip" android:layout_height="25dip" android:src="#555555" /> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="fill_parent"> <ImageView android:id="@+id/image3" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/image4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon" android:scaleType="centerInside" android:maxWidth="35dip" android:maxHeight="50dip" /> </LinearLayout> </LinearLayout>