I want to create a spinner widget, and I added this to string.xml
:
JavaScript
x
<string-array name="options">
<item>All Tasks</item>
<item>Today's Tasks</item>
<item>Tomorrow's Tasks</item>
<item>Archived Tasks</item>
</string-array>
and I adapted it:
JavaScript
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.options, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
and I got a build error:
JavaScript
Cause: startElement.getAttributeByName(QName("name")) must not be null
How can I solve this?
Advertisement
Answer
Special character like apostrophe(‘) are not allowed in xml directly Use can use escape sequences to get the desired result.
Replace: Today’s by Today ‘s
Use a backslash symbol before apostrophe ‘