Spinner的基本使用
来源:互联网 发布:淘宝上共享账号下软件 编辑:程序博客网 时间:2024/06/08 15:04
一个下拉列表的实现,这里记录下,下拉列表是如何实现的:
(1)布局:
<Spinner android:id="@+id/sp_xinjian" android:layout_width="match_parent" android:layout_height="wrap_content"/>
(2)Item:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tv_changneizuoye_xinjian" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="内容" /></LinearLayout>
(3)Activity中:
private Spinner sp_xinjian;sp_xinjian = (Spinner) findViewById(R.id.sp_xinjian);// 给Adapter填充数据,mZhiLing为String数组,这里不写里,内容自己准备就行 adapter_zhiling = new ArrayAdapter<String>( getApplicationContext(), R.layout.changneizuoye_xianjian_item, R.id.tv_changneizuoye_xinjian, mZhiLing); // 设置适配器,显示 sp_xinjian.setAdapter(adapter_zhiling);
(4)(根据需要)默认显示:
如果想要默认显示哪一项内容的话,可以再加一句:
//i为数组的下标sp_xinjian.setSelection(i, true);
(5)(根据需要)样式:
下拉列表的样式是可以自己更改的,需要写个styles,这里不介绍了。
本文出自 “移动平台开发” 博客,请务必保留此出处http://liuxudong1001.blog.51cto.com/10877072/1734551
阅读全文
0 0
- Spinner的基本使用
- Spinner的基本使用
- Spinner的基本使用
- <Android>控件Spinner的基本使用
- Android基本控件之Spinner的使用
- marsAndroid学习——spinner的基本使用
- (Spinner) android中Spinner的使用
- Spinner 的使用
- Spinner控件的使用
- Spinner的使用
- Spinner的使用
- Spinner的简单使用
- Android Spinner的使用
- Spinner控件的使用
- spinner的使用详解
- spinner组件的使用
- android spinner的使用
- Spinner的使用
- Volley的Post用法
- 开始
- GIT 源码阅读之 init-db
- Android中如何获取经纬度
- 欢迎使用CSDN-markdown编辑器
- Spinner的基本使用
- 显示当前时间对话框
- 如何让EditText禁止调用小键盘
- 使用 Alpha 通道为图像加水印
- styleable
- 利用popupwindow生成带有列表的对话框,并设置对话框列表的点击事件
- SQL Server 2014 安装图解
- 混乱字符串的字段提取
- Android根据已知的经纬度坐标获取当前位置