一个下拉列表的实现,这里记录下,下拉列表是如何实现的:
创新互联是一家集网站建设,盘龙企业网站建设,盘龙品牌网站建设,网站定制,盘龙网站建设报价,网络营销,网络优化,盘龙网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
(1)布局:
<Spinner android:id="@+id/sp_xinjian" android:layout_width="match_parent" android:layout_height="wrap_content"/>
(2)Item:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tv_changneizuoye_xinjian" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000" android:text="内容" /> </LinearLayout>
(3)Activity中:
private Spinner sp_xinjian; sp_xinjian = (Spinner) findViewById(R.id.sp_xinjian); // 给Adapter填充数据,mZhiLing为String数组,这里不写里,内容自己准备就行 adapter_zhiling = new ArrayAdapter<String>( getApplicationContext(), R.layout.changneizuoye_xianjian_item, R.id.tv_changneizuoye_xinjian, mZhiLing); // 设置适配器,显示 sp_xinjian.setAdapter(adapter_zhiling);
(4)(根据需要)默认显示:
如果想要默认显示哪一项内容的话,可以再加一句:
//i为数组的下标 sp_xinjian.setSelection(i, true);
(5)(根据需要)样式:
下拉列表的样式是可以自己更改的,需要写个styles,这里不介绍了。
新闻名称:Spinner的基本使用
网址分享:https://www.cdcxhl.com/article26/pgdecg.html
成都网站建设公司_创新互联,为您提供微信小程序、面包屑导航、品牌网站建设、用户体验、App开发、网站设计
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联