Android:设计一个简单的调查问卷

Android:设计⼀个简单的调查问卷
设计⼀个简单的调查问卷,要求⽤到TextView,Button,CheckBox,RadioButton,EditText等控件
今天写了⼀个demo,⾥⾯⽤到了常⽤的布局,以及常⽤的⼏种控件,这⾥调查问卷名字为⼤学⽣⽇常消费调查问卷,是参考⽹上的常⽤调查问卷,选择了⼏个问题,为了省事,这⾥我只选择了6个问题,最终效果:⽤户填写完调查问卷,点击提交,页⾯跳转到另⼀个结果页⾯,显⽰⽤户提交的数据结果,当点击提交时如果有未填项,则不能跳转。主要为了练习常⽤布局以及控件的使⽤。
最终效果图
设计要点:
1. 使⽤ScrollView 来实现屏幕的滚动效果;
2. RadioGroup与RadioButton的配合使⽤;
3. RadioGroup与CheckBox事件监听的实现;
4. 显⽰页⾯QuestionnaireActivity与结果页⾯QuestionnaireResultActivity之间数据的传递;
其中问卷显⽰页⾯代码如下
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="schemas.android/apk/res/android"
xmlns:app="schemas.android/apk/res-auto"
xmlns:tools="schemas.android/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEEEEE"
tools:context="i.layout.Questionnaire"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:background="#0099FF"
android:text="⼤学⽣⽇常消费调查问卷"
android:textSize="25dp"
android:textColor="@color/white"
/>
<!--性别-->
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="1.您的性别是:"
android:textSize="25dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/
>
<RadioGroup
android:id="@+id/rg_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@color/white"
>
<RadioButton
android:id="@+id/rb_man"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"
android:textSize="25dp"
/>
<RadioButton
android:id="@+id/rb_woman"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="⼥"
android:textSize="25dp"
/>
</RadioGroup>
在线销售系统<!--2.院系-->
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="2.您的院系是:"
android:textSize="25dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<RadioGroup
android:id="@+id/rg_department"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"> <RadioButton
android:id="@+id/rb_department1"
android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="软件学院"
android:textSize="25dp"
展示架制作android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_department2"
android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="计算机学院"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_department3"
android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="外语学院"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_department4"
android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="其他学院"
android:textSize="25dp"
android:paddingTop="5dp"
/>
</RadioGroup>
<!--3.年级-->
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"            android:text="3.您的年级是:"
android:textSize="25dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<RadioGroup
android:id="@+id/rg_grade"
android:layout_width="match_parent"
android:layout_height="wrap_content"            android:orientation="vertical"
android:background="@color/white"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"> <RadioButton
android:id="@+id/rb_grade1"
android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="⼤⼀"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_grade2"
android:layout_height="wrap_content"
android:text="⼤⼆"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_grade3"
android:layout_width="match_parent"
解子征
android:layout_height="wrap_content"
android:text="⼤三"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_grade4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="⼤四"
android:textSize="25dp"
android:paddingTop="5dp"
/>
</RadioGroup>
<!--4.每⽉消费-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4.您的在校期间平均⽉消费为:"            android:textSize="25dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<RadioGroup
耐酸碱保护膜android:id="@+id/rg_consume"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<RadioButton
android:id="@+id/rb_consume1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="600以下"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_consume2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="600-1000"
android:textSize="25dp"
智慧农业控制系统android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_consume3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1000-1500"
android:textSize="25dp"
android:paddingTop="5dp"
/>
<RadioButton
android:id="@+id/rb_consume4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1500元以上"
android:textSize="25dp"
android:paddingTop="5dp"
/>
</RadioGroup>
<!--5.主要消费⽤途-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="5.您每⽉消费主要在哪些⽅⾯:"            android:textSize="25dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<CheckBox
android:id="@+id/cb_mainconsume_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="A.伙⾷"/>
<CheckBox
android:id="@+id/cb_mainconsume_b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="B.购物(服装、饰品)"/> <CheckBox
android:id="@+id/cb_mainconsume_c"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="C.学习费⽤(书籍)"/>
<CheckBox
android:id="@+id/cb_mainconsume_d"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="D.娱乐"/>
<CheckBox
垃圾分拣机器人android:id="@+id/cb_mainconsume_e"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="E.上⽹消费"/>
<CheckBox
android:id="@+id/cb_mainconsume_f"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="F.恋爱"/>
<CheckBox
android:id="@+id/cb_mainconsume_g"
android:layout_width="match_parent"

本文发布于:2024-09-23 16:14:21,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/4/277402.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:调查   问卷   提交   实现   学院   效果   点击   问题
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议