Java tutorial
//package com.java2s; import android.graphics.drawable.Drawable; import android.os.Build; import android.view.View; public class Main { public static void setBackground(View v, Drawable background) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { v.setBackground(background); } else { v.setBackgroundDrawable(background); } } }