I am currently using the Switch Widget which supposedly came in API 14. My project is set to a min API of 15. I am trying to change the background of the Switch widget track OnCheckedChanged
but i get an error that setTrackResource needs a minimum API of 16.. I thought at first i just needed to update my support library but its on v13
I don't want to @supress this warning? is there a way around it?
cameraTypeSwitch = (Switch) findViewById(R.id.cameraTypeSwitch);
cameraTypeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (buttonView.isChecked()){
cameraTypeSwitch.setTrackResource(R.drawable.camera_track_camera);
}
else{
cameraTypeSwitch.setTrackResource(R.drawable.camera_track_video);
}
}
});
i tried to set the track drawable to have an on checked state like so:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@null" android:state_enabled="false"/>
<item android:drawable="@drawable/camera_track_camera" android:state_checked="true"/>
<item android:drawable="@drawable/camera_track_video" android:state_checked="false"/>
</selector>
but that doesn't seem to work.. is there anyway to dynamically change the track background in API 15