I am writing a custom Preference
. I can easily read attribute values in my private namespace:
public MyPreference(Context context, AttributeSet attrs)
{
super(context, attrs);
TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.MyPreference);
mDefaultValue = styledAttrs.getInt(R.styleable.MyPreference_defaultValue, 0);
}
But I do not know, how to read android attributes, e.g. android:defaultValue
. In all examples on the web attributes contain values, but I use resources like @integer/my_number
so simply reading attrs
does not work - attribute contains resource reference but not the value. android.R.styleable is not accessible, so I do not understand how to do it.