您的位置:首页 > 移动开发 > Android开发

Android中spinner的简单用法(1)

2015-09-28 11:32 399 查看
这里因为mainActivity的代码简单不用修改,用直接生成的代码即可。

main.xml代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context="com.example.spnner.MainActivity" >

<TextView android:id="@+id/spinnerText"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello_world"

/>

<Spinner

android:id="@+id/Spinner01"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/spinnerText"

android:layout_below="@+id/spinnerText"

android:entries="@array/xiexing" //重点在以下两行,@在我认为,相当于一个指针,可以指向某一个位置。在以下代码中有具体体现。

android:prompt="@string/spin_prompt" />

</RelativeLayout>

string.xml代码:

<?xml version="1.0" encoding="utf-8"?>

<resources>

<string name="app_name">Spnner</string>

<string name="hello_world">你的血型</string>

<string name="action_settings">Settings</string>

<string name="spin_prompt">请选择血型</string>

<string-array name="xiexing">

<item>A型</item>

<item>B型</item>

<item>AB型</item>

<item>O型</item>

<item>其他</item>

</string-array>

</resources>

此为spinner的一个简单运用,只是通过string和main来实现的,没有Java程序,所以内容单调,

目的只是为了熟悉一下spinner的一些用法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: