I am writing a custom preference dialog derived from DialogPreference
and I want to pass some custom attributes to the dialog through the
preference's XML definition.
Here's my preference.xml file:
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myns="http://schemas.android.com/apk/res/
com.mycompany.android">
<PreferenceCategory
android:title="Preferences">
<com.mycompany.SeekBarPreference
android:key="xxx"
android:title="yyy"
android:summary="zzz"
myns:labelMin="Shorter"
myns:labelMax="Longer"
myns:valueMin="1"
myns:valueMax="10"
myns:valueDefault="5"
/>
I defined the following attrs.xml under res/values folder
<resources>
<declare-styleable name="SeekBarPreference">
<attr name="labelMin" format="string"/>
<attr name="labelMax" format="string"/>
<attr name="valueMin" format="integer"/>
<attr name="valueMax" format="integer"/>
<attr name="valueDefault" format="integer" />
</declare-styleable>
</resources>
In the constructor my my preference dialog, I do:
public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
TypedArray a = this.context.obtainStyledAttributes(attrs,
R.styleable.SeekBarPreference);
minValue = a.getInteger(R.attr.valueMin, 0);
minLabel = a.getString(R.attr.labelMin);
}
However, the line "a.getIneger()" is throwing a ArrayIndexOutOfBounds
exception.
Any suggestions?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---