Ich habe erklärt folgendes declare-stylables in attr.xml:Wie man Integer Resource Array durch Typed-Array erhalten?
<declare-styleable name="SideSpinnerAttrs">
<attr name="stringValues" format="reference" />
<attr name="iconIDs" format="reference"/>
</declare-styleable>
Array von Ressourcen Symbolen in array.xml:
<integer-array name="spinnerIcons">
<item>@drawable/ic_attachment_black_24dp</item>
<item>@drawable/ic_audiotrack_black_24dp</item>
<item>@drawable/ic_slideshow_black_24dp</item>
</integer-array>
Ich möchte und diese Symbole von Array ein Set rufen Imageview:
private void readSpinnerIcons(Context context, AttributeSet attrs) {
TypedArray icons=context.obtainStyledAttributes(attrs,R.styleable.SideSpinnerAttrs);
int id=icons.getResourceId(R.styleable.SideSpinnerAttrs_iconIDs,0);
int[] i=getResources().getIntArray(id);
spinner_icon.setBackgroundResource(i[0]);
}
Aber Array "int [] i" ist leer. Warum?