【发布时间】:2014-10-16 23:56:45
【问题描述】:
我有子类偏好,并在 attrs.xml 中创建了自定义样式,如下所示:
<declare-styleable name="MyPreference">
<attr name="myAttribute" format="reference" />
</declare-styleable>
我可以在 xml 中声明我的偏好,如下所示:
<com.my.project.MyPreference
android:title="myTitle"
namespace:myAttribute="@array/sleep_time_values" />
我可以访问自定义属性就好了:
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyPreference, 0, 0);
thing = a.getText(R.styleable.MyPreference_myAttribute);
我的问题是:如何访问(在代码中)上面 xml 定义中指定的内部 android:title 属性?
【问题讨论】: