Reputation: 19149
Custom attributes are great, but all tutorials mention usage in custom views where you have AttributeSet parameter ready.
Contents of my attrs.xml:
<declare-styleable name="StyledDialogs">
<attr name="sdlDialogStyle" format="reference" />
</declare-styleable>
<declare-styleable name="DialogStyle">
...
</declare-styleable>
I'm struggling how to access those attributes in any class outside custom view.
Upvotes: 0
Views: 1983
Reputation: 19149
After a few hours, I have figured out a way which works:
final TypedArray a = mContext.getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);
Upvotes: 2