安卓学习-界面-ui-Spinner
属性
属性 | 方法 | 说明 |
android:entries | 设置下拉内容 | |
android:dropDownHorizontalOffset | 下拉框的水平偏移,没效果 | |
android:dropDownVerticalOffset | 下拉框的垂直偏移,没效果 | |
android:dropDownWidth | 下拉列表的宽度,没效果 | |
android:popupBackground | 下拉列表的背景色,没效果 | |
android:prompt |
下拉列表的提示信息 |
例子1
直接指定android:entries,就比较简陋的,但一般的选择框已经够用了
items.xml
<?xml version="1.0" encoding="utf-8"?> <resources><string-array name="ys"><item >红色</item><item >绿色</item><item >黄色</item></string-array> </resources>
View Code
activity_main.xml
<RelativeLayout 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"tools:context="${relativePackage}.${activityClass}" ><Spinnerandroid:id="@+id/spinner1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true" android:entries="@array/ys"/></RelativeLayout>
View Code
例子2:带图片的
直接用了SimpleAdapter,当然也可以直接继承BaseAdapter,反正和ListView一样
item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent" android:padding="10dp"><ImageViewandroid:id="@+id/imageView1"android:layout_width="50dp"android:layout_height="50dp" /><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Large Text"android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>
View Code
activity_main.xml
<RelativeLayout 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"tools:context="${relativePackage}.${activityClass}" ><Spinnerandroid:id="@+id/spinner1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true" android:entries="@array/ys"/></RelativeLayout>
View Code
MainActivity.java
public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();Map<String, Object> map1 = new HashMap<String, Object>();map1.put("pic", R.drawable.myd_1);map1.put("name", "满意");items.add(map1);Map<String, Object> map2 = new HashMap<String, Object>();map2.put("pic", R.drawable.myd_2);map2.put("name", "一般");items.add(map2);Map<String, Object> map3 = new HashMap<String, Object>();map3.put("pic", R.drawable.myd_3);map3.put("name", "不满意");items.add(map3);SimpleAdapter sa = new SimpleAdapter(MainActivity.this, items,R.layout.item, new String[] { "pic", "name" }, new int[] {R.id.imageView1, R.id.textView1 });Spinner spinner=(Spinner)findViewById(R.id.spinner1);spinner.setAdapter(sa);} }
View Code
转载于:https://www.cnblogs.com/weijj/p/3957202.html
安卓学习-界面-ui-Spinner相关推荐
- 安卓学习总结-UI开发流程
最近做的工作,主要是对安卓的一系列UI组件的开发,在完成设计需求的过程中,对UI开发流程有了一点小想法,今天来把他们总结一下. UI开发流程图 一.了解安卓中的View体系 在UI开发的过程中,我们一 ...
- 安卓学习-界面-View的自定义
android的所有UI控件,都是基于View的,因此特意重点学习了下这个,为后面学习其他控件打下基础. 参照了疯狂android讲义和http://blog.csdn.net/guolin_blog ...
- 安卓学习-界面-布局-FrameLayout
类似于动画里的帧布局,是一层一层的 FrameLayout直接继承了ViewGroup,常用的XML属性 属性 方法 说明 android:foreground setForeground(Drawa ...
- 安卓学习 之 UI控件(三)
一.常用控件 1.TextView(文本) match_parent:控件与父类相同(基本不用fil_parent)wrap_content:刚好包裹里面内容. android:gravity调节文字 ...
- 安卓学习-界面-ui-ListView
ListView继承自AbsListView AbsListView属性 XML属性 代码 说明 android:choiceMode setChoiceMode(int choiceMode) A ...
- 安卓学习-界面-ui-RadioButton CheckBox
RadioButton CheckBox 下面例子演示了2个功能,一个是RadioButton选择时的事件,还有一个是Button按钮点击查看这2个控件的属性 XML代码 <RelativeL ...
- 安卓学习-界面-ui-Toast
Toast提示信息,直接上例子 两个按钮,第一个是普通的,第二个是自定义的 view1.xml 自定义视图 <LinearLayout xmlns:android="http:/ ...
- java实现图形界面输入半径求圆面积_测试开发工程师系列之Android自动化测试Appium(Python)连载(7)安卓图形界面...
安卓图形界面 UI即User Interface(用户界面)的简称.泛指用户操作界面,包含移动APP,网页,智能穿戴设备等.Android用户界面测试,要测试应用程序如何与一个真实的用户交互.这种测试 ...
- 安卓学习笔记3——登录界面UI
安卓学习笔记3--登录界面UI 一.登录界面UI 1.根据需求写UI 2.主活动 3.主活动调用的读写文件的工具类 4.效果展示 二.总结与改进 不足: 1.密码分割采用字符串:当密码和用户名包含该字 ...
- app界面设计是什么?需要学习什么UI软件
什么是app界面设计?其实app界面设计,又称为UI设计.我们常说的UI设计,其实是一种针对软件的人机交互.操作逻辑.界面美观的整体设计. UI设计师必须掌握的一项技能,就是会使用app界面UI设计软 ...
最新文章
- 视频: 猫和老鼠真实版
- 基于 Kafka + Flink + Redis 的电商大屏实时计算案
- JQuery预加载的四种种方式
- 二叉搜索树(BFS)总结
- C语言实现升序优先队列Ascending priority queue(附完整源码)
- 在ASP.Net Core 中使用枚举类而不是枚举
- Windows服务编写
- c语言中的所有代码大全,C语言库函数代码大全
- python学习之路(17)
- request,response传入线程值会变为null
- python统计字符串中某个字符出现的次数_【面试题总结】1、统计字符串中某个字符出现的次数(2-Python实现)...
- pthread_cond_timedwait方法Linux时间编程
- 如何使用自訂 Segue 實現視圖轉場動畫
- 枚举---知识总结----------gyy加以整理以及改为C++方法
- 【年度总结】于无声处听惊雷-2016年度总结
- 一英寸芯片大小_CCD芯片尺寸
- 三星 android 模拟器下载地址,GalaxyOfWar电脑版下载 安卓模拟器图文安装教程
- element ui表单必填_element ui判断是否必填添加校验
- 编译安装baas平台-cello-h3c
- 手淘flexible适配终端方案(一)