自定义属性很棒,但所有教程都提到了在自定义视图中的用法,在自定义视图中,AttributeSet参数已经准备好了。
我的attrs.xml的内容:
<declare-styleable name="StyledDialogs">
<attr name="sdlDialogStyle" format="reference" />
</declare-styleable>
<declare-styleable name="DialogStyle">
...
</declare-styleable>我正在为如何在自定义视图之外的任何类中访问这些属性而苦苦挣扎。
发布于 2013-06-28 03:00:39
几个小时后,我想出了一个可行的方法:
final TypedArray a = mContext.getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle, R.attr.sdlDialogStyle, 0);https://stackoverflow.com/questions/17351182
复制相似问题