How to read attributes from android namespace in user preferences?

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.

+4
source share

Source: https://habr.com/ru/post/1390848/


All Articles