基本设置参照 http://imshare.iteye.com/blog/770950
页面显示的内容和弹出框不同的设置:
titleSpinner.setPrompt("请选择服务网点范围:"); //设置弹出框提示信息 titleSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { // TODO Auto-generated method stub TextView txtView = (TextView)view; txtView.setText("办税服务网点("+listSpinner.get(pos)+")"); } }
spinner 样式自定义参考
http://www.pocketdigi.com/20111206/587.html
只要提供显示样式和弹出样式就可以实现不同效果
显示样式设置
spinnerAdapter = new ArrayAdapter<String>(this,R.layout.spinner_style, listSpinner);
R.layout.spinner_style是自定义样式
<?xml version="1.0" encoding="utf-8"?> <!-- /* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml ** ** Copyright 2006, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerItemStyle" android:singleLine="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:ellipsize="marquee" />
弹出样式设置
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
android.R.layout.simple_spinner_dropdown_item 这个是系统定义的样式,也可以自定义一个样式类似下面的
<?xml version="1.0" encoding="utf-8"?> <!-- /* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml ** ** Copyright 2008, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:ellipsize="marquee" />
更多参考http://www.android-doc.com/reference/android/widget/Spinner.html
相关推荐
Android spinner 案例Android spinner 案例Android spinner 案例
Android Spinner实现图片列表;通常的Spinner只能展示文字列表,此demo实现了Spinner展示图片列表。 支持sdk2.2及以上版本。
Xamarin.Android Spinner的简单示例。包括用法,载入等。
android spinner的前面设置图标android spinner的前面设置图标android spinner的前面设置图标android spinner的前面设置图标android spinner的前面设置图标
android spinner控件添加,删除使用源代码 android spinner控件添加,删除使用源代码
android spinner的简单代码 只有几行
在这个例子中包括了众多Android Spinner 控件的用法,以一个下拉框的效果来展示很多Spinner 的使用技巧,示例中的myspinner_dropdown自定义下拉菜单模式定义在res/layout目录下,代码中演示了将ArrayAdapter添加...
Android Spinner控件简单使用方法,图片加文字的展示效果
简单的设置spinner默认的标题 例如“请选择”等等
可以记住历史选项的Android spinner
利用android中的spinner控件 实现了全国省市三级联动
我们大家都应该知道,android给我们提供了一个spinner控件,这个控件主要就是一个列表。 Spinner位于 android.widget包下,每次只显示用户选中的元素,当用户再次点击时,会弹出选择列表供用户选择,而选择列表中的...
android Spinner 简单快速的显示
这个demo是关于android中Spinner控件的使用(Spinner就是下拉框)。 需求:在Spinner实现取value值与text值。 如有BUG 或者不完善,欢迎小伙伴们提出~
android Spinner应用实例。
android spinner 省份市二级联动 android端实现两个spinner的二级联动
1 仿web页面做出的下拉列表,已经妥善处理,派生接口,可以随意实现功能; 2.汇聚Java设计模式于其中,精美封装,直接套用;
android spinner使用案例 本人初学android控件 以此记录学习心得 上传于此分享给大家学习
android Spinner+sqlite 三级联动
该源代码展示了如何去实现下拉列表框的效果,控件Spinner