效果显示:
定义控件:
<android
.support
.v7
.widget
.AppCompatSpinner
android
:id
="@+id/spinner"
android
:layout_width
="wrap_content"
android
:layout_height
="wrap_content"
android
:entries
="@array/ctype"
/>
定义下拉菜单的内容:
<?xml version
="1.0" encoding
="utf-8"?>
<resources
>
<string
-array name
="ctype">
<item
>随便
</item
>
<item
>旅游
</item
>
<item
>游戏
</item
>
<item
>娱乐
</item
>
<item
>日记
</item
>
<item
>格言
</item
>
<item
>思考
</item
>
<item
>学习
</item
>
</string
-array
>
</resources
>
获取内容:
定义:
private AppCompatSpinner spinner
;
id:
spinner
=findViewById(R
.id
.spinner
);
获取:
s1
=spinner
.getSelectedItem().toString();
转载请注明原文地址:https://ipadbbs.8miu.com/read-52377.html