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