I have a spinner now and I want to load the data to the spinner with data binding feature. I tried to find the way to declare the string array in the XML(https://developer.android.com/topic/libraries/data-binding/index.html#expression_language) but no satisfied result is found.
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:apps="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.util.SparseArray"/>
<variable
name="statuslist"
type="SparseArray<String>"/>
</data>
...
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spn_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner1"
android:layout_below="@+id/btn2"
android:entries="@{statuslist}"
apps:adapter="@{statusAdapter}"/>
</layout>
When it is build, the following error is shown.
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'.
org.xml.sax.SAXParseException; systemId: file:/C:/Users/../app/build/intermediates/res/merged/debug/layout/testdialog.xml; lineNumber: 24; columnNumber: 30; The value of attribute "type" associated with an element type "null" must not contain the '<' character.
However, there is something confused.
- When I tried to use SparseArray as shown on website. I found a "Cannot resolve sysmbol" in Android Studio XML Editor.
- I do not know is it the correct way to setup the array value for the spinner since there is no official instructions for the spinner data bindingin the website.