Spinner 用法
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spinner弹框模式"/>
<Spinner
android:id="@+id/SpinnerTK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnerMode="dialog">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spinner带标题的弹框模式"/>
<Spinner
android:id="@+id/SpinnerTKTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/prompt"
android:spinnerMode="dialog">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spinner复杂下拉框"/>
<Spinner
android:id="@+id/SpinnerImageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:prompt="@string/prompt"
android:spinnerMode="dropdown">
</Spinner>
后台代码
Spinner spxl = (Spinner) findViewById(R.id.SpinnerXL);
Spinner sptk = (Spinner) findViewById(R.id.SpinnerTK);
Spinner sptktitle = (Spinner) findViewById(R.id.SpinnerTKTitle);
List listdata = new ArrayList<>();
for (int ii = 0; ii < 50; ii++) {
listdata.add("数据" + ii);
}
ArrayAdapter adapter = new ArrayAdapter<>(BtnActivity.this, android.R.layout.simple_list_item_1, listdata);
spxl.setAdapter(adapter);
sptk.setAdapter(adapter);
sptktitle.setAdapter(adapter);
spxl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(BtnActivity.this, "选择了:" + parent.getItemAtPosition(position), Toast.LENGTH_SHORT).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Spinner spimagetext = (Spinner) findViewById(R.id.SpinnerImageText);
list = getData();
MyCustomAdapter myCustomAdapter = new MyCustomAdapter(list, BtnActivity.this);
spimagetext.setAdapter(myCustomAdapter);
spimagetext.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (!firstSelect) {
Toast.makeText(BtnActivity.this, "你选择了:" + list.get(position).get("name").toString(),
Toast.LENGTH_SHORT).show();
} else {
firstSelect = false;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Button btntab=(Button)findViewById(R.id.btntab);
btntab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(BtnActivity.this,TabBottom.class);
startActivity(intent);
}
});
}
ArrayList<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map;
private boolean firstSelect=true;
private ArrayList<Map<String,Object>> getData() {
map=new HashMap<String, Object>();
map.put("image",R.drawable.ic_home_black_24dp);
map.put("name","日历");
map.put("desc","descdescdescdesc");
list.add(map);
map=new HashMap<String, Object>();
map.put("image",R.drawable.ic_dashboard_black_24dp);
map.put("name","相机");
map.put("desc","descdescdescdesc");
list.add(map);
map=new HashMap<String, Object>();
map.put("image",R.drawable.ic_notifications_black_24dp);
map.put("name","闹钟");
map.put("desc","descdescdescdesc");
list.add(map);
map=new HashMap<String, Object>();
map.put("image",R.drawable.ic_home_black_24dp);
map.put("name","游戏控制");
map.put("desc","descdescdescdesc");
list.add(map);
return list;
}
}
Spinner 用法的更多相关文章
- Spinner用法与ListView用法
参考: http://blog.csdn.net/u012960536/article/details/46732421 --------------------------------------- ...
- 三、spinner
今天 ,看的和学的都不多,就弄了一个spinner控件而已,下面就记录一下spinner 用法吧 基本上说,使用spinner 有三个步骤 一.在布局文件里面设置spinner 控件,这个不用再多说了 ...
- 表单(下)-EasyUI Spinner 微调器、EasyUI Numberspinner 数值微调器、EasyUI Timespinner 时间微调器、EasyUI Slider 滑块
EasyUI Spinner 微调器 扩展自 $.fn.validatebox.defaults.通过 $.fn.spinner.defaults 重写默认的 defaults. 微调器(spinne ...
- Android UI自定义Spinner下拉框(用popuwindow实现)-转
定义出第一个图片的布局和弹出框(一个listView)的布局,,这里就不在多说了~ListView需要自己定义一个MyspinnerAdapter~做好这些准备之后,就是弹出框的实现了~ prote ...
- android-Spinner的学习和使用
Spinner下拉列表的使用和功能 执行步骤: * 1.添加一个下拉列表项的list * 2.为下拉列表定义一个数组适配器(ArrayAdapter),添加数据资源 * 3.位适配器设置下拉列表下拉时 ...
- easyui表单插件-包括日期时控件-列表
← jQuery EasyUI 表单插件 – Numberspinner 数值微调器 jQuery EasyUI 表单插件 - Timespinner 时间微调器 jQuery EasyUI 插件 ...
- Android移动软件开发总结
目录 Android实验参考目录 常用知识点总结 服务绑定bind Service ThreadService使用总结 Service用法总结 Broadcast Receiver用法 Intent使 ...
- android之Spinner控件用法
用法1: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...
- Android Spinner的简单用法。
今天学到的是spinner,就是下拉列表,这可不是ExpandListView哈. 闲话不解释.这是控件,所以先上布局:就不上线性布局了,基本上可以总结出,控件都得在布局里写,写之前嵌个布局就行. & ...
随机推荐
- zookeeper基本知识和zk作用体现
有一段时间没写博客,今天想着把自己近几个月做的笔记分享一波. 前两个月我一直在看zk的视频:https://coding.imooc.com/learn/list/201.html 从开始看这位老 ...
- 将项目导入myeclipse后 tortoise svn 右键项目不能更新和提交
使用 tortoise svn客户端将svn服务器上的项目checkout之后正常,可以更新也可以提交:当将这个项目导入MyEclipse之后,不能更新和提交了只出现svn升级工作副本这一字样:网上搜 ...
- Flask添加新命令
代码: import click from flask import Flask app = Flask(__name__) @app.cli.command() def hg(): click.ec ...
- rpm方式安装MySQL后在命令行登录报错:ERROR 1045 (28000): Unknown error 1045
1.通过https://mirrors.tuna.tsinghua.edu.cn镜像源安装了MySQL5.7.22 rpm -ivh --force --nodeps https://mirrors. ...
- SecureCRT语法高亮设置
因为默认情况下,SecureCRT不能显示语法高亮特性,整个界面颜色单一,看起来不爽,也没有效率,所有通过设置一下语法高亮还是很有必要的, 默认字体也看着不是很清晰,还是更改为我比较喜欢的Courie ...
- CountDownLatch源码探究 (JDK 1.8)
CountDownLatch能够实现让线程等待某个计数器倒数到零的功能,之前对它的了解也仅仅是简单的使用,对于其内部如何实现线程等待却不是很了解,最好的办法就是通过看源码来了解底层的实现细节.Coun ...
- scrapy爬虫-scrapy-redis分布式
1.如何将一个scrapy爬虫项目修改成为一个简单的分布式爬虫项目 官方文档:https://scrapy-redis.readthedocs.io/en/stable/ 只用修改scrapy项目的两 ...
- AF(操作者框架)系列(3)-创建第一个Actor的程序
这节课的内容,语言描述基本是无趣的,就是一个纯程序编写,直接上图了. 如果想做其他练习,可参考前面的文章: https://zhuanlan.zhihu.com/p/105133597 1. 新建一个 ...
- tfgan折腾笔记(三):核心函数详述——gan_loss族
gan_loss族的函数有: 1.gan_loss: 函数原型: def gan_loss( # GANModel. model, # Loss functions. generator_loss_f ...
- Flink系列之状态及检查点
Flink不同于其他实时计算的框架之处是它可以提供针对不同的状态进行编程和计算.本篇文章的主要思路如下,大家可以选择性阅读. 1. Flink的状态分类及不同点. 2. Flink针对不同的状态进行编 ...