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哈. 闲话不解释.这是控件,所以先上布局:就不上线性布局了,基本上可以总结出,控件都得在布局里写,写之前嵌个布局就行. & ...
随机推荐
- 使用 Hexo 在 GitHub 上建立博客 · Utopia's Daily Note
使用 Hexo 在 GitHub 上建立博客 # 写在前面 其实我在一月份的就开始写了三篇博客文章,你没有看错,只是写了三篇,然后,就没有然后了.我还在其中一篇文章中写着,不知道自己能够坚持多久.事实 ...
- ant:如何用ant将web project打包成war包
说明:src中的文件将不会呈现出来,诸位可以自己写一个简单的web项目,然后依照我所提供的ant脚本配置来设置. 文件结构如图所示: 配置为下: build.xml < ...
- Proto3:C++基本使用
本教程提供protocol buffer在C++程序中的基础用法.通过创建一个简单的示例程序,向你展示如何: 在.proto中定义消息格式 使用protocol buffer编译器 使用C++ pro ...
- 查漏补缺:socket编程:TCP粘包问题和常用解决方案(上)
1.TCP粘包问题的产生(发送端) 由于TCP协议是基于字节流并且无边界的传输协议,因此很容易产生粘包问题.TCP的粘包可能发生在发送端,也可能发生在接收端.发送端的粘包是TCP协议本身引起的,TCP ...
- hiho一下:Beautiful String
hiho一下:Beautiful String 记不清这是 hiho一下第几周的题目了,题目不难,不过对于练习编程,训练思维很有帮助.况且当时笔者处于学习算法的早期, 所以也希望刚接触算法的同学能多去 ...
- Design Patterns 25
尽管将一个系统分割成许多对象通常可以增加其可服用性, 但是对象间相互连接的激增又会降低其可复用性了. 大量的连接使得一个对象不可能在没有改变其他对象的支持下工作, 系统表现为一个不可分割的整体, 所以 ...
- springmvc两种配置方法
基于配置文件xml方式, 配置springmvc步骤: 1.在pom文件中引入jar包: <!--导入springmvc的jar包--> <dependency> <gr ...
- Chrome 插件安装时报错: "CRX_HEADER_INVALID"
1. 将 crx 插件后缀名改为 rar 2. 解压 rar 包 3. 进入浏览器 1). 点击Chrome浏览器地址栏最右边的三个点 --> 更多工具 --> 扩展插件 --> 点 ...
- Python安装3 —— Python3.8和2.7共存
本文内容皆为作者原创,如需转载,请注明出处:https://www.cnblogs.com/xuexianqi/p/12400896.html 一:Python解释器为什么要2个版本? 众所周知,Py ...
- 操作系统-IO管理和磁盘调度
I/O设备 IO设备的类型 分为三类:人机交互类外部设备:打印机.显示器.鼠标.键盘等等.这类设备数据交换速度相对较慢,通常是以字节为单位进行数据交换的 存储设备:用于存储程序和数据的设备,如磁盘.磁 ...