Spinner用法案例
Spinner控件也是一种列表类型的控件,它的继承关系如下:
java.lang.Object
↳ android.view.View
↳ android.view.ViewGroup
↳ android.widget.AdapterView<T extends android.widget.Adapter>
↳ android.widget.AbsSpinner
↳ android.widget.Spinner
android.widget.Spinner继承了android.view.ViewGroup类。下面安排一个案例如图6-5,有两个Spinner,颜色选择Spinner和星座选择Spinner。点击颜色选择Spinner右边的 按钮,如图6-6所示,弹出单选对话框。图6-7 星座选择Spinner
程序代码请参考代码清单6-3:
【代码清单6-3】 chapter6_2/src/com/work/SpinnerActivity.java
public class SpinnerActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView txt2 = (TextView) findViewById(R.id.TextView02);
Spinner s1 = (Spinner) findViewById(R.id.Spinner01);
final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.colors, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
s1.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(
AdapterView<?> parent, View view, int position, long id) {
txt2.setText(adapter.getItem(position).toString());
}
public void onNothingSelected(AdapterView<?> parent) {
txt2.setText("没选中的");
}
});
final TextView txt4 = (TextView) findViewById(R.id.TextView04);
Spinner s2 = (Spinner) findViewById(R.id.Spinner02);
ArrayAdapter<CharSequence> adapterC = new ArrayAdapter<CharSequence>(this,
android.R.layout.simple_spinner_item, CONSTELLATIONS);
adapterC.setDropDownViewResource(android.R.layout.simple_spinner_item);
s2.setAdapter(adapterC);
s2.setOnItemSelectedListener(
new OnItemSelectedListener() {
public void onItemSelected(
AdapterView<?> parent, View view, int position, long id) {
txt4.setText(CONSTELLATIONS[position]);
}
public void onNothingSelected(AdapterView<?> parent) {
txt4.setText("没选中的");
}
});
}
static final String[] CONSTELLATIONS = new String[] {
"白羊座", "金牛座", "双子座",
"巨蟹座", "狮子座", "处女座",
"天枰座", "天蝎座", "射手座",
"魔蝎座", "水瓶座", "双鱼座"
};
}http://heziji0672.blog.com/
http://ancxj.blog.com/
http://shangxiong00737.blog.com/
http://ki8912.blog.com/
http://cangxi4868.blog.com/
http://xuji1231.blog.com/
http://shanjing8665.blog.com/
http://zhe782.blog.com/
http://ranzhuida775.blog.com/
http://lai6713.blog.com/
http://feitunsi36.blog.com/
http://sad8812.blog.com/
http://zhaopousha79787.blog.com/
http://kasid98.blog.com/
http://shimeici184015.blog.com/
http://anha7821.blog.com/
http://zaiyouy7202.blog.com/
http://sadko981.blog.com/
http://rendeng182212.blog.com/
http://ki8123.blog.com/
http://yixiemi13415.blog.com/
http://ki78912.blog.com/
http://zhituian1653.blog.com/
http://m81231.blog.com/
http://qiaogang1659.blog.com/
http://hewr81.blog.com/
http://aoaode39831.blog.com/
http://lusx712.blog.com/
http://keyongzh5221.blog.com/
http://ls7121.blog.com/
http://congluji2808.blog.com/
http://basi7812.blog.com/
http://weixia9836.blog.com/
http://xuays121.blog.com/
http://xiongrenche14.blog.com/
http://yuxuanji.blog.com/
http://qingma9737.blog.com/
http://jua7812.blog.com/
http://shangfei95393.blog.com/
http://xias1231.blog.com/
http://muliecan7113.blog.com/
http://has8121.blog.com/
http://congshi2329.blog.com/
http://xinahui91.blog.com/
http://pinfudui67883.blog.com/
http://jzin7891.blog.com/
http://renjia1161.blog.com/
http://jinliufu.blog.com/
http://ganwolun1706.blog.com/
http://jinliud12.blog.com/
http://yagangxin01050.blog.com/
http://miasd712.blog.com/
http://xianzh5942.blog.com/
http://xiuas81.blog.com/
http://liangpanzh00386.blog.com/
http://you8121.blog.com/
http://naohanba97971.blog.com/
http://xibai11.blog.com/
http://zenjiehua3187.blog.com/
http://zuqqiubao.blog.com/
http://naowengj3291.blog.com/
http://kamai412.blog.com/
http://weizijing43227.blog.com/
http://huangdaxian.blog.com/
http://mumenlu860.blog.com/
http://maimawz.blog.com/
http://huancaol58001.blog.com/
http://hdxjsz.blog.com/
http://youjipu5744.blog.com/
http://lhcqnc.blog.com/
http://chenp8205.blog.com/
http://usd9812.blog.com/
http://fanganf6957.blog.com/
http://tsp4887.blog.com/
http://jiyouxin8565.blog.com/
http://xg140kj.blog.com/
http://xinxia0141.blog.com/
http://xg112kj.blog.com/
http://yajia7668.blog.com/
http://c6cccc.blog.com/
http://chifeila119.blog.com/
http://kaijiangjg.blog.com/
http://zhaoedui29882.blog.com/
http://zhu109kj.blog.com/
http://difutu91605.blog.com/
http://xg2014k.blog.com/
http://benjiyi42440.blog.com/
http://sad11211.blog.com/
http://ougangdo774.blog.com/
http://fggslt.blog.com/
http://xinpanjiu33.blog.com/
http://huangdaxianlt.blog.com/
http://songsh841.blog.com/
http://kj2014jl.blog.com/
http://jixiongj0406.blog.com/
http://jixiongj0406.blog.com/
http://lujiaora89681.blog.com/
http://tiesua121.blog.com/
http://cheaos7036.blog.com/
http://haungdax.blog.com/
http://kensimen390.blog.com/
http://caibaw.blog.com/
http://yuelu26090.blog.com/
http://xgd83q.blog.com/
http://haihaojia75906.blog.com/
http://xiangg897.blog.com/
http://yixinsha86009.blog.com/
http://ad1211.blog.com/
http://shoux70498.blog.com/
http://liuha99.blog.com/
http://zhibaof6829.blog.com/
http://kai891.blog.com/
http://moubeichui62690.blog.com/
http://xinshui888.blog.com/
http://cizongn442.blog.com/
http://ss4378.blog.com/
http://xingshiyao70920.blog.com/
http://zx8901.blog.com/
http://chaopa2652.blog.com/
http://dahux89.blog.com/
http://bufeiye51126.blog.com/
http://shensuana.blog.com/
http://zhisongx358.blog.com/
http://guanjiapo.blog.com/
http://ganxiaj094.blog.com/
http://xihu787.blog.com/
http://cuanzizh9727.blog.com/
http://dzi8uu.blog.com/
http://jiyanya73561.blog.com/
http://kjq101.blog.com/
Spinner用法案例相关推荐
- python面向对象三大特性_Python面向对象之多态原理与用法案例分析
本文实例讲述了Python面向对象之多态原理与用法.分享给大家供大家参考,具体如下: 目标 多态 面向对象三大特性 封装 根据 职责 将 属性 和 方法 封装 到一个抽象的 类 中 定义类的准则 继承 ...
- python中的多态用法_Python面向对象之多态原理与用法案例分析
本文实例讲述了Python面向对象之多态原理与用法.分享给大家供大家参考,具体如下: 目标 多态 面向对象三大特性 封装 根据 职责 将 属性 和 方法 封装 到一个抽象的 类 中 定义类的准则 继承 ...
- ListView分页(带图片)显示用法案例
ListView是Android中最为常用的列表类型控件,ListView中的选择项目中样式很多有的是纯文字的.有的还可以带有图片.它的继承关系如下: java.lang.Object ↳ a ...
- uni-app watch computed API作用语法用法 +案例
一.computedAPI 1.1前言:在模板中,可以通过插值语法显示一些data中的数据,但是在某些情况下,一些数据可能需要进行转换后再显示eg:需要对多个data数据进行进行运算.三元运算符来决定 ...
- MVC4 jquery 样式 主题 用法(案例)
开发工具:VS2012 MVC版本:MVC4 MVC4已经自带了jquery,新建的项目,基本上什么都不用添加就可以运行,跑项目.(集成了那么多东西,jquery,modernizr,自带的默认权限, ...
- JAVA知识点 HashSet 集合的用法[案例+代码+总结]
文章目录 前言 一.HashSet 集合的存储 二.将Object类存入HashSet 总结 前言 HashSet 是 Set 接口的一个实现类,它所存储的元素是不可重复的,并且元素都是无序的.这个必 ...
- MySQL六种窗口函数用法案例
Java和大数据系列 注:大家觉得博客好的话,别忘了点赞收藏呀,本人每周都会更新关于人工智能和大数据相关的内容,内容多为原创,Python Java Scala SQL 代码,CV NLP 推荐系统等 ...
- java list详解_Java 中 list 用法案例详解
LIST是个容器接口可以理解为动态数组,传统数组必须定义好数组的个数才可以使用,而容器对象无须定义好数组下标总数,用add()方法即可添加新的成员对象,他可以添加的仅仅只能为对象,不能添加基本数据类型 ...
- python中continue用法案例_记录今天学习python中for与while循环针对break和continue的用法...
python中有两个主要的循环for与while,其中针对这两个循环有两种不同的中断用法break与continue. 首先先看下面的循环代码: 1: for i in range(10):#变量i带 ...
最新文章
- Freemarker + xml 实现Java导出word
- 移动应用开发者正饱受折磨
- Elasticsearch聚合 之 Date Histogram聚合
- 面试问题:SpringMVC的执行流程
- 3650m5设置u盘启动_联想和华硕笔记本重装系统时新BIOS无法设置u盘启动怎么办
- 2013年C++A:神奇的算式
- C语言的面向对象设计之 X264,FFMPEG 架构探讨
- RHEL6 下搭建 nginx + uwsgi + cgi 平台
- mysql免费版稳定吗_mysql免费版好用么
- 松下弧焊机器人 调电压_松下焊接机器人-基本操作篇.pdf
- 操作必须使用一个可更新的查询
- 多屏信号服务器,多屏图像拼接处理器 多种信号输出输入
- SpringBoot自定义Starter(二十四)
- 好看的php登录界面,php注册和登录界面的实现案例(推荐)
- 人工智能终究会抢了我们程序员的饭碗
- Poj 1328 Radar Installation 贪心
- MacBook将大文件分割成很多个小文件split命
- rk键盘快捷键快捷键不一致_为什么其他键盘语言的键盘快捷键和可访问性很少起作用...
- C# 处理PPT水印(三)—— 在PPT中添加多行(平铺)文本水印效果
- [空间记录]嚯哈哈,空间访问量突破一万,纪念一下.