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