Spinner为下拉列表,可以通过ArrayAdater数组适配器配置文字下拉列表,也可以通过SimpleAdater简单适配器配置图文下拉列表。这些控件都类似于ListView组件的使用,适配器详解具体参考Android开发笔记—ListView的基础使用
效果图
xml文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.jialin.spinnerdemo.MainActivity">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="简单适配器!" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"