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哈. 闲话不解释.这是控件,所以先上布局:就不上线性布局了,基本上可以总结出,控件都得在布局里写,写之前嵌个布局就行. & ...
随机推荐
- jsPDF
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- POJ 2112 Optimal Milking 最短路 二分构图 网络流
题意:有C头奶牛,K个挤奶站,每个挤奶器最多服务M头奶牛,奶牛和奶牛.奶牛和挤奶站.挤奶站和挤奶站之间都存在一定的距离.现在问满足所有的奶牛都能够被挤奶器服务到的情况下,行走距离的最远的奶牛的至少要走 ...
- The Monster(Codeforce-C-思维题)
C. The Monster time limit per test 1 second memory limit per test 256 megabytes As Will is stuck i ...
- Matplotlib简单回顾
import numpy as np from pylab import * from matplotlib import pyplot as plt x = [1, 2, 3, 4] y = [3, ...
- 前进中的人工智能——聚焦Faculty Summit 2015人工智能主题研讨会
Summit 2015人工智能主题研讨会" title="前进中的人工智能--聚焦Faculty Summit 2015人工智能主题研讨会"> 在近几年上映的科幻大 ...
- 7/8段码管(LED)
LED显示器在许多的数字系统中作为显示输出设备,使用非常广泛.它的结构是由发光二极管构成的a.b.c.d.e.f和g七段,并由此得名,实际上每个LED还有一个发光段dp,一般用于表示小数点,所以也有少 ...
- Centos7.X 搭建Prometheus+node_exporter+Grafana实时监控平台
Prometheus简介 什么是 Prometheus Prometheus是一个开源监控报警系统和时序列数据库 主要功能 多维数据模型(时序由 metric 名字和 k/v 的 labels 构成) ...
- .NET Core 获取程序运行环境信息与反射的应用
目录 RuntimeInformation.Environment 获取信息 反射获取信息 获取某个属性的值以及别名 反射获取信息 使用 总结 笔者的九篇反射系统文章已经完结,但是笔者会持续更新反射在 ...
- Dubbo中@Service工作过程解析
Dubbo中@Service工作过程解析 Spring中的BeanPostProcessor 首先我们应当了解到在spring体系中BeanPostProcessor是什么.加载流程 它是什么 Bea ...
- 解决微信小程序视频组件层级过高的问题
本文首发于我的个人博客:http://www.fogcrane.org 前言 在微信小程序的开发中,总有一些"VIP"组件,他们的层级,高得让人抓狂,总是凌驾于很多其他低层级组件之 ...