Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.drawable.BitmapDrawable; import android.view.View; import java.io.InputStream; public class Main { /** * Method setBackgroundImage */ public static void setBackgroundImage(Context context, View view, int resId) { InputStream inStream = context.getApplicationContext().getResources().openRawResource(resId); BitmapDrawable drawable = new BitmapDrawable(inStream); view.setBackgroundDrawable(drawable); } }