2012-08-03 149 views
0

我想讀的方式與偏好文件如下所示的屬性:偏好屬性不能正常工作

boolean status = attrs.getAttributeBooleanValue(PREFERECES_NS, ATTR_DEFAULT_VALUE, false) 

我無法弄清楚,爲什麼狀態變量始終是假的,而不管分配給首選項文件中屬性的值。

回答

0

我從來沒有使用getAttributeBooleanValue()方法解決這個問題。但是,此問題的解決方法是:

attributes = context.obtainStyledAttributes(attrs,R.styleable.yourFullPackageName_ClassName); 

status = attributes.getBoolean(R.styleable.yourFullPackageName_ClassName_YourAttributeNameFromPreferencesFile, false);