I want to change the layout background by clicking a button, but a red underline occurs in layoutname.setBackground(drawable) which says that I should have minimum SDK version 16 and not 9 (which I have) My question is, the following code I use to check is proper?
Resources res = getResources(); //resource handle
Drawable drawable = res.getDrawable(R.drawable.gradientblue);
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
LinearForColor.setBackgroundDrawable(drawable);
} else {
LinearForColor.setBackground(drawable);
}