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, for example. android:defaultValue . All the examples in the web attributes contain values, but I use resources such as @integer/my_number , so just reading attrs does not work - the attribute contains a link to the resource, but not the value. android.R.styleable is not available, so I donโt understand how to do this.
source share