xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><HorizontalScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"><LinearLayoutandroid:layout_width="wrap_content"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="30dp"android:text="你来自于那个省?"android:textSize="25sp"/><Spinnerandroid:layout_width="300dp"android:layout_height="wrap_content"android:id="@+id/spinner_pro"android:layout_marginLeft="30dp"/><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="30dp"android:text="你来自于哪个城市?"android:textSize="25sp"/><Spinnerandroid:layout_width="300dp"android:layout_height="wrap_content"android:id="@+id/spinner_city"android:layout_marginLeft="30dp"/><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="30dp"android:text="你来自于哪个班级?"android:textSize="25sp"/><AutoCompleteTextViewandroid:layout_width="300dp"android:layout_height="wrap_content"android:textSize="22sp"android:layout_margin="30dp"android:id="@+id/autotext"/><CheckBoxandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/a"android:text="a"/><CheckBoxandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/b"android:text="b"/><CheckBoxandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/c"android:text="c"/><CheckBoxandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/d"android:text="d"/><CheckBoxandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/e"android:text="e"/><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/button"android:text="按键"/></LinearLayout><ListViewandroid:layout_width="400dp"android:layout_height="match_parent"android:id="@+id/mylist"android:layout_margin="30dp"/><ListViewandroid:layout_width="400dp"android:layout_height="match_parent"android:id="@+id/myADlist"android:layout_margin="30dp"/><GridViewandroid:layout_width="900dp"android:layout_height="match_parent"android:id="@+id/myADgrid"android:layout_margin="30dp"android:numColumns="3"/></LinearLayout></HorizontalScrollView>
</LinearLayout>

Java文件

public class threeActivity extends AppCompatActivity {Spinner Spinner_Pro, Spinner_City;AutoCompleteTextView AutoText;ListView LV, LV_AD;GridView GV_AD;String[] String_Pro = {"广东省", "广西省", "福建省", "海南省", "浙江省", "江苏省","湖南省", "湖北省", "安徽省", "江西省", "山东省", "河南省","山西省", "河北省", "黑龙江", "辽宁省", "吉林省", "内蒙古","新疆", "西藏", "宁夏", "青海省", "台湾省", "甘肃省","北京", "天津", "重庆", "四川省", "云南省", "上海"};ArrayList arrayList = new ArrayList();String[] StudentName = {"黄琼妮", "刘君豪", "尹冠朗", "梁雁廷","赖泽华", "黄瑾勋", "李兆涯", "邓维晟", "吴忠飞", "陈首源","卢培纯", "梁海亮", "吴金柱", "孙杰", "蓝子健", "刘宇康","王春豪", "谢桩", "刘艳君", "林康杰", "郭之泳", "丁争彦","周烙谦", "陈佳伟", "叶景宙", "叶苏贵", "唐瑾", "吴孟联",};String[] StudentNum = {"17115062029", "18125041001", "18125041002", "18125041003","18125041009", "18125041010", "18125041011", "18125041012", "18125041014","18125041017", "18125041019", "18125041024", "18125041029", "18125041032","18125041033", "18125041034", "18125041035", "18125041044", "18125041045","18125041046", "18125041047", "18125041050", "18125041051", "18125041053","18125041054", "18125041055", "18125041057", "18125041058",};int[] HeadPic = {R.mipmap.ab, R.mipmap.ch, R.mipmap.cl,R.mipmap.cwt, R.mipmap.cxk, R.mipmap.dc, R.mipmap.dlrb,R.mipmap.glnz, R.mipmap.he, R.mipmap.hjh, R.mipmap.hzt, R.mipmap.jd,R.mipmap.lb, R.mipmap.lcr, R.mipmap.lcy, R.mipmap.ldh,R.mipmap.lh, R.mipmap.lmg, R.mipmap.lmyz, R.mipmap.lq,R.mipmap.lyf, R.mipmap.qzy, R.mipmap.tly, R.mipmap.wy,R.mipmap.wyb, R.mipmap.ym, R.mipmap.zbc, R.mipmap.zjl,R.mipmap.zly, R.mipmap.zry, R.mipmap.zyl, R.mipmap.zyx};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.three_layout2);setTitle("123");Button();Spinner_Pro = findViewById(R.id.spinner_pro);Spinner_City = findViewById(R.id.spinner_city);AutoText = findViewById(R.id.autotext);LV = findViewById(R.id.mylist);LV_AD = findViewById(R.id.myADlist);GV_AD = findViewById(R.id.myADgrid);final ArrayList arrayListpro = new ArrayList<String>();for (int i = 0; i < String_Pro.length; i++) {arrayList.add(String_Pro[i]);}ArrayAdapter arrayAdapter = new ArrayAdapter<String>(threeActivity.this,android.R.layout.simple_spinner_item,arrayList);arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);Spinner_Pro.setAdapter(arrayAdapter);Spinner_Pro.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {@Overridepublic void onItemSelected(AdapterView<?> parent, View view, int position, long id) {Toast.makeText(threeActivity.this, "我来自于" + String_Pro[position], Toast.LENGTH_SHORT).show();}@Overridepublic void onNothingSelected(AdapterView<?> parent) {}});ArrayAdapter<CharSequence> Adapter_City = ArrayAdapter.createFromResource(threeActivity.this, R.array.city, android.R.layout.simple_spinner_item);Adapter_City.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);Spinner_City.setAdapter(Adapter_City);Spinner_City.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {@Overridepublic void onItemSelected(AdapterView<?> parent, View view, int position, long id) {String[] cityname = getResources().getStringArray(R.array.city);Toast.makeText(threeActivity.this, "我的城市是" + cityname[position].toString(), Toast.LENGTH_SHORT).show();}@Overridepublic void onNothingSelected(AdapterView<?> parent) {}});ArrayAdapter<CharSequence> Adapter_glass = ArrayAdapter.createFromResource(threeActivity.this,R.array.glass,android.R.layout.simple_list_item_1);AutoText.setAdapter(Adapter_glass);ArrayAdapter listAdapter = new ArrayAdapter(threeActivity.this,android.R.layout.simple_list_item_1,arrayListpro);LV.setAdapter(listAdapter);LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {Toast.makeText(threeActivity.this, "我点击的是" + String_Pro[position].toString(), Toast.LENGTH_SHORT).show();}});ArrayList<HashMap<String, Object>> users = new ArrayList<HashMap<String, Object>>();for (int i = 0; i < StudentName.length; i++) {HashMap<String, Object> user = new HashMap<String, Object>();user.put("img", HeadPic[i]);user.put("name", StudentName[i]);user.put("num", StudentNum[i]);user.put("hometown", String_Pro[i]);users.add(user);}SimpleAdapter StudentAdapter = new SimpleAdapter(threeActivity.this,users,R.layout.item_layout,new String[]{"img", "name", "num", "hometown"},new int[]{R.id.pic_head, R.id.tx_name, R.id.tx_num, R.id.tx_home});LV_AD.setAdapter(StudentAdapter);LV_AD.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {Toast.makeText(threeActivity.this, StudentName[position].toString(), Toast.LENGTH_SHORT).show();}});GV_AD.setAdapter(StudentAdapter);}}

新建一个XML文件

<?xml version="1.0" encoding="utf-8"?><resources><string-array name="city"><item>韶关</item><item>广州</item><item>深圳</item><item>珠海</item><item>中山</item><item>茂名</item><item>云浮</item><item>潮州</item></string-array><string-array name="glass"><item>18物联网1班</item><item>18物联网2班</item><item>18物联网3班</item><item>18物联网4班</item><item>18通信工程1班</item><item>18通信工程2班</item><item>18通信工程3班</item><item>17通信工程1班</item><item>17通信工程2班</item><item>17通信工程3班</item></string-array>
</resources>

Android_水平滚动控件HorizontalScrollView相关推荐

  1. android横向滑动控件,Android学习——HorizontalScollview水平滚动控件

    HorizatalScollView控件只是支持水平滚动,而且它只能包含一个控件,通常是在标签中定义一个 标签并且在标签中android:orientation属性值设置为horization.然后在 ...

  2. Android 第十八课 强大的滚动控件 RecyclerView

    步骤: 一.添加依赖库 compile'com.android.support:recyclerview-v7:26.1.0' 二.在activity_mian.xml中,添加RecyclerView ...

  3. 滚动控件(ScrollBar)

    滚动控件(ScrollBar) 滚动条(ScrollBar)主要用来从某一预定义值范围内快速有效地进行选择.滚动条分垂直滚动条和水平滚动条两种.在滚动条内有一个滚动框,用来表示当前的值.用鼠标单击滚动 ...

  4. QML_滚动控件Scroll

    QML_滚动控件Scroll 滚动控件Scroll属性: 1. active : bool,保存滚动条是否处于活跃状态 2.horizontal : bool,保存滚动条是否为水平 3.interac ...

  5. Android 循环滚动控件ViewFlipper,可实现跑马灯或轮播图效果

    ViewFlipper--Android循环滚动控件 1.效果如下: 2.实现方法 (1)创建进出动画 上下滚动动画 y_in.xml <?xml version="1.0" ...

  6. ScrollView垂直滚动控件

    ScrollView垂直滚动控件 一.简介 二.方法 1)ScrollView垂直滚动控件使用方法 1.在layout布局文件的最外层建立一个ScrollView控件 2.在ScrollView控件中 ...

  7. Android之滚动控件Recycler

    Activity之滚动控件Recycler 基本用法 RecyclerView 不仅实现了和 ListView 同样的效果,而且还优化了 ListView 存在的各种不足. RecyclerView ...

  8. Android快速入门之滚动控件RecyclerView

    之前已经用过了ListView控件,虽然可以实现许多放入功能,但是其扩展性还是有一定缺陷的,比如所无法实现横向布局,为此,Android中提供了一个更强大的滚动控件--RecyclerView,它可以 ...

  9. Android滚动字幕公告字过长时横向滚动控件

    Android滚动字幕公告字过长时横向滚动控件 效果 Gradle 使用 属性 地址 效果 字体长度过大滚动字体,结束后上下滚动公告控件 Gradle repositories { maven { u ...

最新文章

  1. python希尔排序的优缺点_Python排序搜索基本算法之希尔排序实例分析
  2. 学习前端html 设置样式
  3. img打 webpack_webpack打包html里面img后src为“[object Module]”问题
  4. [JS-BOM]BOM_Location地址栏对象
  5. 第二次作业—熟悉使用工具
  6. windows7下redis的安装实践
  7. 《Web漏洞防护》读书笔记——第7章,访问控制防护
  8. 小巧的KML文件生成工具KML Generator
  9. 机器学习-降维方法-有监督学习:LDA算法(线性判别分析)【流程:①类内散度矩阵Sw->②类间散度矩阵Sb->计算Sw^-1Sb的特征值、特征向量W->得到投影矩阵W->将样本X通过W投影进行降维】
  10. Captin for mac(大小写切换悬浮窗提示)
  11. 我学炒外汇 第二十二篇实战心得
  12. 2019上半年软件设计师 下午真题-简答题及免费答案(一)
  13. python输出成绩分析代码_Python根据成绩分析系统浅析
  14. 指令系统 —— 指令格式
  15. # 前后端国际化多语言配置
  16. 发送短信验证码到手机(阿里大于平台) java
  17. Quectel EC600N-CN 中尺寸物联网首选LTE Cat 1模块[移远通信]
  18. linux_ rpm管理(Synaptic Package Manager)
  19. 《java编程思想》读书笔记【前言】
  20. 如何在DXP中进行任何形状的敷铜?

热门文章

  1. windows 下使用nginx 实现负载均衡
  2. 畅邮(DM Pro)-一款强悍、纯净而稳定的重量级电子邮箱客户端(支持分发、追踪)
  3. matlab 图片雾化代码,雾化效果图片制作代码汇总
  4. python-docx文档高亮显示
  5. 【基于物理的渲染(PBR)白皮书】(五)几何函数相关总结
  6. Android之在app图标添加角标
  7. 基于Java/Mysql的个人博客网站
  8. 低成本打造初创团队的 DevOps 实践(采用 NAS中的KVM 承载 Gogs + Jenkins + Nexus 服务)【0x02】安装Nexus
  9. Android练手小项目--仿72g赚吧App
  10. 6种品牌打印机介绍及打印机旗舰店推荐