I use custom xml attributes for preferences. The preferences are inflated from xml.
I managed to create and read custom xml attributes for EditTextPreference, ListPreference and CheckBoxPreference by creating custom classes which inherit from the respective preference class.
In the constructor of the class I can read the attributes like so:
public class CustomTextPreference extends EditTextPreference {
public CustomTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,R.styleable.PreferenceCustomAttrs);
x = a.getString(R.styleable.PreferenceCustomAttrs_x);
y = a.getString(R.styleable.PreferenceCustomAttrs_y);
}
}
My problem is that I can't do this for the PreferenceScreen class, as it is a final class. So my question is: Is there any way I can read the custom attributes of a PreferenceScreen?