这里是我使用的代码:设置样式不能得到解决
public ASSwitch(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray sharedTypedArray = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.ASSwitch,
0, 0);
try {
onText = sharedTypedArray.getText(R.styleable.ASSwtich_onText, null);
} finally {
sharedTypedArray.recycle();
}
}
这里是(增加值的文件夹)的文件attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="ASSwitch">
<attr name="onText" format="string" />
<attr name="offText" format="string" />
<attr name="onState" format="boolean" />
<attr name="toogleDrawable" format="string" />
<attr name="frameDrawable" format="string" />
</declare-styleable>
</resources>
在这些问题couldn的答案”解决问题。请不要认为我的问题是重复的。
更新:看来我导入了错误的R类。应用程序的R
类不是android.R
。
如果这是答案,那么请接受您自己的答案,以帮助未来的访问者。这就是Stack Overflow的工作原理。请参阅[如何接受答案?](http://meta.stackexchange.com/q/5234/173448)。 – jww