Spinner是android的一种控件,用它我们可以实现下拉框。
我们先来看一下效果图
这是一个很简单的功能,上面一个TextView,下面一个Spinner,TextView用于显示Spinner选择的选项。
下面我们就来看一下实现吧。
首先,我们先在xml文件中将spinner写出
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
android:layout_width="match_paren