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