在API16之后View的setBackground代替了setBackgroundDrawable,解决版本兼容的代码:
if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.setBackgroundDrawable(drawable);
} else {
view.setBackground(drawable);
}