</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 用法的更多相关文章

  1. Spinner用法与ListView用法

    参考: http://blog.csdn.net/u012960536/article/details/46732421 --------------------------------------- ...

  2. 三、spinner

    今天 ,看的和学的都不多,就弄了一个spinner控件而已,下面就记录一下spinner 用法吧 基本上说,使用spinner 有三个步骤 一.在布局文件里面设置spinner 控件,这个不用再多说了 ...

  3. 表单(下)-EasyUI Spinner 微调器、EasyUI Numberspinner 数值微调器、EasyUI Timespinner 时间微调器、EasyUI Slider 滑块

    EasyUI Spinner 微调器 扩展自 $.fn.validatebox.defaults.通过 $.fn.spinner.defaults 重写默认的 defaults. 微调器(spinne ...

  4. Android UI自定义Spinner下拉框(用popuwindow实现)-转

    定义出第一个图片的布局和弹出框(一个listView)的布局,,这里就不在多说了~ListView需要自己定义一个MyspinnerAdapter~做好这些准备之后,就是弹出框的实现了~  prote ...

  5. android-Spinner的学习和使用

    Spinner下拉列表的使用和功能 执行步骤: * 1.添加一个下拉列表项的list * 2.为下拉列表定义一个数组适配器(ArrayAdapter),添加数据资源 * 3.位适配器设置下拉列表下拉时 ...

  6. easyui表单插件-包括日期时控件-列表

    ← jQuery EasyUI 表单插件 – Numberspinner 数值微调器 jQuery EasyUI 表单插件 - Timespinner 时间微调器  jQuery EasyUI 插件 ...

  7. Android移动软件开发总结

    目录 Android实验参考目录 常用知识点总结 服务绑定bind Service ThreadService使用总结 Service用法总结 Broadcast Receiver用法 Intent使 ...

  8. android之Spinner控件用法

    用法1: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...

  9. Android Spinner的简单用法。

    今天学到的是spinner,就是下拉列表,这可不是ExpandListView哈. 闲话不解释.这是控件,所以先上布局:就不上线性布局了,基本上可以总结出,控件都得在布局里写,写之前嵌个布局就行. & ...

随机推荐

  1. [洛谷P1495] 曹冲养猪 (中国剩余定理模板)

    中国剩余定理(朴素的)用来解线性同余方程组: x≡a[1] (mod m[1]) x≡a[2] (mod m[2]) ...... x≡a[n] (mod m[n]) 定义ms=m[1]*m[2]*. ...

  2. Ruby爬虫header发送cookie,nokogiri解析html数据

    之前用php写过一个爬虫,同样是获取局域网的网站数据,这次我使用相同的网络环境,更低的电脑配置,使用ruby来再次爬虫,惊人的发现ruby使用自带的类库net/http爬取速度要远远超过php的cur ...

  3. Bar条形图

    import matplotlib.pyplot as plt import numpy as np n = 12 X = np.arange(n) Y1 = (1 - X / float(n)) * ...

  4. 混乱中的ICO平台,会不会是下一个P2P的重灾区?

    当众多巨头和创业者还在为共享打车.共享单车.VR.IP化.互联网金融沉迷时,一种全新的"众筹"正在造就一个又一个暴富神话.其名为ICO,即首次代币众筹,一般指区块链初创项目在众筹平 ...

  5. redis实现二级缓存

    缓存的作用就是降低数据库的使用率,来减轻数据库的负担.我们平常的操作一般都是查>改,所以数据库的有些查操作是重复的,如果一直使用数据库就会有负担.Mybatis也会做缓存,也会有一级缓存和二级缓 ...

  6. 【Java】macOS下编译JDK8

    安装mercurial brew install mercurial 下载源码 1234 hg clone http://hg.openjdk.java.net/jdk8/jdk8 java-sour ...

  7. ConcurrentHashMap源码探究 (JDK 1.8)

    很早就知道在多线程环境中,HashMap不安全,应该使用ConcurrentHashMap等并发安全的容器代替,对于ConcurrentHashMap也有一定的了解,但是由于没有深入到源码层面,很多理 ...

  8. vector 循环里删除多个元素

    ; i < (int)vecLines.size(); i++) { AcDbLine * l1 = vecLines[i]; if (l1 == NULL) { continue; } //记 ...

  9. 微服务SpringBoot总结

    什么是SpringBootSpringBoot是Spring项目中的一个子工程,与我们所熟知的Spring-framework 同属于spring的产品官方介绍:Spring Boot makes i ...

  10. flask 参数校验

    校验参数是否存在,不存在返回400 @app.route('/check',methods=['POST']) def check(): values = request.get_json() req ...