且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将数据从xml文件正确加载到Spinner

更新时间:2023-02-07 18:57:30

这就是您获得的垃圾值.

thats the garbage value you getting.

尝试方法,而不是通过适配器编程来设置值.

try this method instead of setting values through adapter programiticaly.

您可以在string.xml中定义字符串数组,并在布局文件中将其设置为spinner

you define string array in string.xml and set it to spinner in your layout file like this

<Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:entries="@array/array_name"
    />