I'm new to android programming . I know some functions and classes were not in first android versions so we have to use different codes to work on different versions. For example to set a Button's background color i should use this code:
// Set button background
if (Build.VERSION.SDK_INT >= 16) {
this.setBackground(background);
} else {
this.setBackgroundDrawable(background);
}
My project's target API version is 11, so setBackground
produces compile error and setBackgroundDrawable
produces deprecation warning, how should i change this code or manifest or etc to make this app work on both versions?
In manifest:
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />