Android 下拉列表Spinner 使用
1、布局文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.helloword.DropListActivity" > <Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/ctype" /> <Spinner android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/> </LinearLayout>
2、arrays.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="ctype">
<item>全部</item>
<item>电影</item>
<item>书籍</item>
<item>体育</item>
<item>文娱</item>
<item>生活</item>
</string-array>
</resources>
3、Activity
package com.example.helloword; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner; public class DropListActivity extends Activity implements View.OnClickListener{ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drop_list); String[] arrayStrings = new String[]{"全部","海贼王","火影忍者","龙珠"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,arrayStrings);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); Spinner spinner = findViewById(R.id.spinner2); spinner.setAdapter(adapter);
} @Override
public void onPointerCaptureChanged(boolean hasCapture) {
// TODO Auto-generated method stub } @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub } }
Android 下拉列表Spinner 使用的更多相关文章
- Android实现三级联动下拉框 下拉列表spinner
Android实现(省.市.县)三级联动下拉框 下拉列表spinner 转载请注明出处: http://www.goteny.com/articles/2013/11/46.html http://w ...
- 【转】Android中Spinner下拉列表(使用ArrayAdapter和自定义Adapter实现)
原文网址:http://embed.21ic.com/software/android/201403/31603.html 1 :Android中Spinner下拉列表(使用ArrayAdapter和 ...
- Android 使用Spinner实现下拉列表
课程目标1.了解Spinner下拉列表的使用和功能2.学会使用系统默认的Spinner3.学会使用自定义样式的Spinner 执行步骤第一步:添加一个下拉列表项的list,这里添加的项就是下拉列表的菜 ...
- Android实现三级联动下拉框下拉列表spinner
原文出处:http://www.cnblogs.com/zjjne/archive/2013/10/03/3350107.html 主要实现办法:动态加载各级下拉值的适配器 在监听本级下拉框,当本级下 ...
- Android下拉列表控件spinner-andoid学习之旅(十一)
废话不多说,下拉列表常用的就是spinner控件. 直接上代码: package peng.liu.testview; import android.app.Activity; import andr ...
- android 开发-spinner下拉框控件的实现
Android提供实现下拉框功能的非常实用的控件Spinner. spinner控件需要向xml资源文件中添加spinner标签,如下: <Spinner android:id="@+ ...
- 下拉列表 Spinner
在Web开发中,HTML提供了下拉列表的实现,就是使用<select>元素实现一个下拉列表,在其中每个下拉列表项使用<option>表示即可.这是在Web开发中一个必不可少的交 ...
- Xamarin.Android之Spinner的简单探讨
一.前言 今天用了一下Spinner这个控件,主要是结合官网的例子来用的,不过官网的是把数据写在Strings.xml中的, 某种程度上,不是很符合我们需要的,比较多的应该都是从数据库读出来,绑定上去 ...
- Android组件Spinner使用
Spinner组件是Android当中非常常用的一种用于下拉选择的组件. 本blog当中主要解决的几个问题: 如何在XML中初始化Spinner选项 如何使用代码的方式初始化Spinner选项 一个A ...
随机推荐
- CentOS7 升级 cmake
编译cmake文件时,报错:CMake 3.0.0 or higher is required. You are running version 2.8.12.2 很明显,这是 cmake 版本过低导 ...
- yum安装python3.6的方法
# centos7 # 换成阿里云的yum源 yum -y install epel-release yum repolist yum -y install python36 测试 [root@loc ...
- [转].gitignore文件不起作用的解决方案
.gitignore文件不起作用的解决方案 觉得有用的话,欢迎一起讨论相互学习~Follow Me 转载地址 https://www.cnblogs.com/liugp/p/10399282.html ...
- SDKMAN一个基于命令行界面的SDK用户环境管理程序
1.背景 使用过Python开发的朋友,应该了解到Python2和Python3语法的差异,有时候从网上下载了基于不同解释器的代码,要来回切换版本, 使用起来不是很方便,有时候甚至很麻烦.于是有人发明 ...
- BeetlConfiguration扩展配置
beetl拓展配置类,绑定一些工具类,方便在模板中直接调用 BeetlConfiguration.java public class BeetlConfiguration extends BeetlG ...
- Mac系统Android 命令行签名
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore keystore文件位置 -signedjar ~/afterSign ...
- .Net Core 3 骚操作 之 用 Windows 桌面应用开发 Asp.Net Core 网站
前言 曾经在开发 Asp.Net 网站时就在想,为什么一定要把网站挂到 IIS 上?网站项目的 Main 函数哪儿去了?后来才知道这个 Main 函数在 w3wp.exe 里,这也是 IIS 的主进程 ...
- 使用Qt画出直方图和分位数图
https://blog.csdn.net/gudanai/article/details/72136420
- find和grep的使用
1.find命令的使用 在Linux中可以使用find命令在指定的目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名,当使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目 ...
- VMnet1、VMnet8到底是什么?
当我们安装VMware Workstation后,在宿主机(物理电脑)上会多出两个网卡,VMNet1.VMNet8,在虚拟机设置里会多出一个配置 VMNet0. vmnet1和vmnet8是两个虚拟网 ...