Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.cgollner.unclouded.preferences;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import com.cgollner.unclouded.R;
public class SwitchPreferenceCompat extends CheckBoxPreference {
public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
public SwitchPreferenceCompat(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public SwitchPreferenceCompat(Context context) {
super(context);
init();
}
private void init() {
setWidgetLayoutResource(R.layout.preference_switch_layout);
}
}
@QuickBrownFoxy
Copy link

QuickBrownFoxy commented Mar 19, 2015

Works good but doesn't not work with TalkBack Accessibility when SwitchCompact used.
Any idea how to get TalkBack to read it?

Everything is OK if Checkbox used

@ursusursus
Copy link

ursusursus commented Aug 25, 2015

any chance of getting animations to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment