这个是一个简单的问卷调查,对于我这样的初学者可能会绞尽脑汁想尽办法,去实现一个看起来特别简单的功能,我这个是用Intent传参的办法,来实现将前边的调查来进行统计,并记录,之后将这些信息显示到最后一个界面,我只做了两个题目的调查,再多个题目也是这样同样的方法来写,对于我来说无任何意义。

第一个布局文件:

  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:id="@+id/LinearLayout1"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:layout_marginTop="12dp"
  7. android:orientation="vertical"
  8. android:paddingBottom="@dimen/activity_vertical_margin"
  9. android:paddingLeft="@dimen/activity_horizontal_margin"
  10. android:paddingRight="@dimen/activity_horizontal_margin"
  11. android:paddingTop="@dimen/activity_vertical_margin"
  12. tools:context=".MainActivity" >
  13.  
  14. <LinearLayout
  15. android:layout_width="wrap_content"
  16. android:layout_height="wrap_content"
  17. android:layout_gravity="center"
  18. android:layout_margin="12dp"
  19. android:gravity="center"
  20. android:orientation="vertical" >
  21.  
  22. <TextView
  23. android:id="@+id/textView1"
  24. android:layout_width="wrap_content"
  25. android:layout_height="wrap_content"
  26. android:layout_gravity="center_horizontal"
  27. android:layout_marginTop="25dp"
  28. android:text="关于APP图标的调查问卷"
  29. android:textSize="22sp" />
  30.  
  31. </LinearLayout>
  32.  
  33. <LinearLayout
  34. android:layout_width="wrap_content"
  35. android:layout_height="wrap_content"
  36. android:layout_gravity="center"
  37. android:layout_marginTop="20dp"
  38. android:orientation="vertical" >
  39.  
  40. <TextView
  41. android:id="@+id/textView2"
  42. android:layout_width="wrap_content"
  43. android:layout_height="wrap_content"
  44. android:layout_marginTop="18dp"
  45. android:text="1.请根据实际来回答问题。"
  46. android:textSize="18dp" />
  47.  
  48. <TextView
  49. android:id="@+id/textView3"
  50. android:layout_width="wrap_content"
  51. android:layout_height="wrap_content"
  52. android:layout_marginTop="18dp"
  53. android:text="2.此问卷为不记名问卷。"
  54. android:textSize="18dp" />
  55.  
  56. <TextView
  57. android:id="@+id/textView4"
  58. android:layout_width="wrap_content"
  59. android:layout_height="wrap_content"
  60. android:layout_marginTop="18dp"
  61. android:text="3.感谢您对此问卷的支持。"
  62. android:textSize="18dp" />
  63.  
  64. </LinearLayout>
  65.  
  66. <TextView
  67. android:id="@+id/textView5"
  68. android:layout_width="wrap_content"
  69. android:layout_height="wrap_content"
  70. android:layout_gravity="center"
  71. android:layout_marginTop="50dp"
  72. android:text="请选择是否开始"
  73. android:textSize="16sp" />
  74.  
  75. <LinearLayout
  76. android:layout_width="229dp"
  77. android:layout_height="wrap_content"
  78. android:layout_gravity="center"
  79. android:layout_marginTop="20dp" >
  80.  
  81. <Button
  82. android:id="@+id/btnStart"
  83. android:layout_width="wrap_content"
  84. android:layout_height="wrap_content"
  85. android:layout_weight="0.50"
  86. android:onClick="startApp"
  87. android:text="开 始" />
  88.  
  89. <Button
  90. android:id="@+id/btnEnd"
  91. android:layout_width="wrap_content"
  92. android:layout_height="wrap_content"
  93. android:layout_marginLeft="30dp"
  94. android:layout_weight="0.50"
  95. android:onClick="endApp"
  96. android:text="退 出" />
  97.  
  98. </LinearLayout>
  99.  
  100. </LinearLayout>

对应的Java文件

  1. package com.yulei.app1;
  2.  
  3. import android.os.Bundle;
  4. import android.app.Activity;
  5. import android.app.AlertDialog;
  6. import android.content.DialogInterface;
  7. import android.content.DialogInterface.OnClickListener;
  8. import android.content.Intent;
  9. import android.view.Menu;
  10. import android.view.View;
  11.  
  12. public class MainActivity extends Activity {
  13.  
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_main);
  18. }
  19.  
  20. @Override
  21. public boolean onCreateOptionsMenu(Menu menu) {
  22. // Inflate the menu; this adds items to the action bar if it is present.
  23. getMenuInflater().inflate(R.menu.main, menu);
  24. return true;
  25. }
  26.  
  27. //开始调查
  28. public void startApp(View v)
  29. {
  30. new AlertDialog.Builder(this)
  31. .setTitle("确认信息")
  32. .setMessage("准备好开始了吗?")
  33. .setPositiveButton("否", null)
  34. .setNegativeButton("是", new OnClickListener() {
  35.  
  36. @Override
  37. public void onClick(DialogInterface arg0, int arg1) {
  38. // TODO Auto-generated method stub
  39. //开始按钮事件
  40. Intent i = new Intent(MainActivity.this , page1.class);
  41. //启动
  42. startActivity(i);
  43. }
  44. })
  45. .show();
  46. }
  47.  
  48. //退出程序
  49. public void endApp(View v)
  50. {
  51. new AlertDialog.Builder(this)
  52. .setTitle("提示信息")
  53. .setMessage("确定退出吗?")
  54. .setPositiveButton("否", null)
  55. .setNegativeButton("是", new OnClickListener() {
  56.  
  57. @Override
  58. public void onClick(DialogInterface arg0, int arg1) {
  59. // TODO Auto-generated method stub
  60. System.exit(0);
  61. }
  62. })
  63. .show();
  64. }
  65.  
  66. }

第一个page1:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. <TextView
  8. android:id="@+id/textView1"
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:layout_gravity="center"
  12. android:layout_marginTop="40dp"
  13. android:text="问卷调查"
  14. android:textSize="24dp" />
  15.  
  16. <LinearLayout
  17. android:layout_width="match_parent"
  18. android:layout_height="wrap_content"
  19. android:layout_marginTop="35dp"
  20. android:orientation="vertical" >
  21.  
  22. <TextView
  23. android:id="@+id/textView2"
  24. android:layout_width="188dp"
  25. android:layout_height="wrap_content"
  26. android:layout_gravity="center"
  27. android:layout_marginTop="16dp"
  28. android:text="1.您的职业为 ?"
  29. android:textSize="20dp" />
  30.  
  31. <RadioGroup
  32. android:id="@+id/radioGroup1"
  33. android:layout_width="184dp"
  34. android:layout_height="wrap_content"
  35. android:layout_gravity="center"
  36. android:layout_marginTop="24dp" >
  37.  
  38. <RadioButton
  39. android:id="@+id/boy"
  40. android:layout_width="wrap_content"
  41. android:layout_height="wrap_content"
  42. android:checked="false"
  43. android:text=" 学生党" />
  44.  
  45. <RadioButton
  46. android:id="@+id/girl"
  47. android:layout_width="wrap_content"
  48. android:layout_height="wrap_content"
  49. android:layout_marginTop="8dp"
  50. android:text=" 上班族" />
  51.  
  52. <RadioButton
  53. android:id="@+id/other"
  54. android:layout_width="wrap_content"
  55. android:layout_height="wrap_content"
  56. android:layout_marginTop="8dp"
  57. android:text=" 其他的" />
  58.  
  59. </RadioGroup>
  60. </LinearLayout>
  61.  
  62. <LinearLayout
  63. android:layout_width="match_parent"
  64. android:layout_height="wrap_content"
  65. android:layout_weight="0.21"
  66. android:orientation="vertical" >
  67.  
  68. <Button
  69. android:id="@+id/btnTijiao"
  70. android:layout_width="123dp"
  71. android:layout_height="wrap_content"
  72. android:layout_gravity="center"
  73. android:layout_marginTop="50dp"
  74. android:onClick="onClickTijiao1"
  75. android:text="提 交" />
  76.  
  77. </LinearLayout>
  78.  
  79. </LinearLayout>

对应Java文件:

  1. package com.yulei.app1;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.ContextMenu;
  7. import android.view.ContextMenu.ContextMenuInfo;
  8. import android.view.View;
  9. import android.widget.RadioButton;
  10. import android.widget.RadioGroup;
  11. import android.widget.TextView;
  12.  
  13. public class page1 extends Activity {
  14.  
  15. public RadioGroup rg;
  16. public RadioButton mRadio1, mRadio2,mRadio3;
  17. String []info=new String [3];
  18. TextView tv1;
  19.  
  20. @Override
  21. protected void onCreate(Bundle savedInstanceState) {
  22. // TODO Auto-generated method stub
  23. super.onCreate(savedInstanceState);
  24. setContentView(R.layout.help);
  25. rg = (RadioGroup) findViewById(R.id.radioGroup1);
  26. mRadio1 = (RadioButton) findViewById(R.id.boy);
  27. mRadio2 = (RadioButton) findViewById(R.id.girl);
  28. mRadio3 = (RadioButton) findViewById(R.id.other);
  29. rg.setOnCheckedChangeListener(radiogpchange);
  30. tv1=(TextView)findViewById(R.id.textView1);
  31. }
  32.  
  33. @Override
  34. public void onCreateContextMenu(ContextMenu menu, View v,
  35. ContextMenuInfo menuInfo) {
  36. // TODO Auto-generated method stub
  37. super.onCreateContextMenu(menu, v, menuInfo);
  38. }
  39.  
  40. private RadioGroup.OnCheckedChangeListener radiogpchange = new RadioGroup.OnCheckedChangeListener()
  41. {
  42. @Override
  43. public void onCheckedChanged(RadioGroup group, int checkedId)
  44. {
  45. if (checkedId == mRadio1.getId())
  46. {
  47. info[0]="学生党";
  48. }
  49. else if (checkedId == mRadio2.getId())
  50. {
  51. info[0]="上班族";
  52. }
  53. else if (checkedId == mRadio3.getId())
  54. {
  55. info[0]="其他的";
  56. }
  57. }
  58. };
  59.  
  60. public void onClickTijiao1(View v)
  61. {
  62. Intent intent=new Intent();
  63. intent.setClass(page1.this,page2.class);
  64. intent.putExtra("info0", info[0]); //put传到另一个界面
  65. //启动
  66. startActivity(intent);
  67. }
  68. }

.

.

.

第三个page3界面:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. <LinearLayout
  8. android:layout_width="match_parent"
  9. android:layout_height="wrap_content"
  10. android:orientation="vertical" >
  11. </LinearLayout>
  12.  
  13. <TextView
  14. android:id="@+id/tvss"
  15. android:layout_width="wrap_content"
  16. android:layout_height="wrap_content"
  17. android:layout_gravity="center"
  18. android:layout_marginTop="50dp"
  19. android:text="调查结果"
  20. android:textSize="20dp" />
  21.  
  22. <TextView
  23. android:id="@+id/textView1"
  24. android:layout_width="wrap_content"
  25. android:layout_height="wrap_content"
  26. android:layout_gravity="center"
  27. android:layout_marginTop="20dp"
  28. android:text="1.你的职业为:"
  29. android:textSize="18sp" />
  30.  
  31. <TextView
  32. android:id="@+id/textView2"
  33. android:layout_width="wrap_content"
  34. android:layout_height="wrap_content"
  35. android:layout_gravity="center"
  36. android:layout_marginTop="20dp"
  37. android:text="2.常用 APP为:"
  38. android:textSize="18sp" />
  39.  
  40. <Button
  41. android:id="@+id/button1"
  42. android:layout_width="133dp"
  43. android:layout_height="wrap_content"
  44. android:layout_gravity="center"
  45. android:layout_marginTop="30dp"
  46. android:onClick="onClickTijiao3"
  47. android:text="确 认 提 交" />
  48.  
  49. </LinearLayout>

对应的Java文件:

  1. package com.yulei.app1;
  2.  
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.content.DialogInterface;
  6. import android.content.DialogInterface.OnClickListener;
  7. import android.content.Intent;
  8. import android.os.Bundle;
  9. import android.view.ContextMenu;
  10. import android.view.ContextMenu.ContextMenuInfo;
  11. import android.view.View;
  12. import android.widget.RadioButton;
  13. import android.widget.RadioGroup;
  14. import android.widget.TextView;
  15.  
  16. public class page3 extends Activity {
  17.  
  18. public RadioGroup rg;
  19. public RadioButton mRadio1, mRadio2,mRadio3;
  20. String []info=new String [3];
  21. TextView tv1,tv2;
  22.  
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. // TODO Auto-generated method stub
  26. super.onCreate(savedInstanceState);
  27. setContentView(R.layout.help3);
  28. tv1=(TextView)findViewById(R.id.textView1);
  29. tv2=(TextView)findViewById(R.id.textView2);
  30.  
  31. }
  32.  
  33. @Override
  34. public void onCreateContextMenu(ContextMenu menu, View v,
  35. ContextMenuInfo menuInfo) {
  36. // TODO Auto-generated method stub
  37. super.onCreateContextMenu(menu, v, menuInfo);
  38. }
  39.  
  40. public void onClickTijiao3(View v)
  41. {
  42. Intent intent = getIntent();
  43. String nn=intent.getStringExtra("info1");
  44. String mm=intent.getStringExtra("info0");
  45. tv1.setText("1.你的职业为:"+mm);
  46. tv2.setText("2.常用 APP为:"+nn);
  47. new AlertDialog.Builder(this)
  48. .setTitle("提示信息")
  49. .setMessage("信息已提交,点击关闭应用")
  50. .setPositiveButton("退 出", null)
  51.  
  52. //.setNegativeButton("是", null)
  53. .show();
  54.  
  55. }
  56. }

在这里不将代码全部贴出来了,运行效果如下所示:

这个程序只是实现了基本的功能,用到的是安卓里边的单击按钮事件以及Activity之间传值。

App下载地址:点击此链接下载此应用

Android_问卷调查的更多相关文章

  1. 网络问卷调查js实现代码

    昨天一个同行妹纸写了一个网络问卷调查的效果,但是有bug,于是就来问我该如何解决这个bug.经过我的分析,bug主要还是出在复选框的那部分,经过修改,bug问题解决,现在贴出如下代码,仅供大家参考: ...

  2. Sharepoint+Office Infopath+快速搭建问卷调查系统

    项目背景 要开发供公司内部使用的N多个在线调查问卷,要求信息在统一的平台上方便跟踪及管理. 公司内部上了Sharepoint系统及大家习惯了使用infopath及Quick app for share ...

  3. [转载]自己编写 php 在线问卷调查程序

        <html> <head> <title>问卷调查</title> <meta http-equiv="Content-Type ...

  4. 北京易信软科信息技术有限公司 问卷调查管理系统V2.0

    北京易信软科信息技术有限公司 问卷调查管理系统V2.0 支持题目模板配置.题型模板配置.选项模板配置,报表查询功能配置 按月建表功能 运用java开发.velocity技术实现页面加载功能,高性能,高 ...

  5. <2048>游戏问卷调查心得与体会

    这是我的首次做问卷调查,刚开始感到不知所措,不知道该怎么去完成它,但是其中也充满了所谓的新鲜感,以前总是填别人做的问卷调查,但是现在是我们小组自己讨论得到的一张属于自己的问卷,可以说感受很深,一张小小 ...

  6. sharepoint2010问卷调查(4)-实现问卷的重复答复次数(采用自定义字段类型和JS)

    sharepoint的问卷调查可以设置重复和一次答复.但是设置一次后,调查过的用户再进行答复.会提示如下图: 分析下:该提示用户体验很不好.给用户感觉是系统出问题了.因此网上有人提出用eventhan ...

  7. sharepoint2010问卷调查(3)-实现问卷的开始和结束时间(采用自定义字段类型)

    接着上面的图片调查,sharepoint自带的问卷调查是没有开始和结束时间的.这个在项目过程不太实用.问卷一般有开始和结束时间的.因此需要自己 动手开发一个自定义字段类型字段.如下图: 开发添加栏目会 ...

  8. sharepoint2010问卷调查(2)-实现问卷的图片调查(采用自定义字段类型)

    1. 首先建立个图片库上传图片 并建立文件夹1和2,1下有1.1文件夹,2下2.1文件夹,2.1下有文件夹2.1.1. 在1文件夹下放如下图片: 2.建立自定义字段类型,如下图: 3.部署后建立栏目的 ...

  9. 简单版问卷调查系统(Asp.Net+SqlServer2008)

    1.系统主要涉及以下几个表  问卷项目表(Q_Naire) 问卷题目表(Q_Problem) 题目类型表(Q_ProblmeType) 题目选项表(Q_Options) 调查结果表(Q_Answer) ...

随机推荐

  1. What Is Your Grade?

    Problem Description “Point, point, life of student!”This is a ballad(歌谣)well known in colleges, and ...

  2. HDU1253 胜利大逃亡(BFS) 2016-07-24 13:41 67人阅读 评论(0) 收藏

    胜利大逃亡 Problem Description Ignatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会. 魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示 ...

  3. iterm2 学习笔记

    itrem 笔记 选中即复制,有两种方式. 在新Tab中自动使用前一Tab路径,该怎么用? 系统热键:option+space 自动完成:输入打头几个字母,然后输入command+“;” iterm2 ...

  4. 二:nodejs+express+redis+bootstrap table+jquery UI

    介绍:做一个量化投资的实时系统. 综合: 添加记录,顺序改变的话,refresh之后,能正常刷新吗?可以正常刷新,只是顺序又变回去. express中用fs readfile 时,需要用path.jo ...

  5. Spring容器中bean的生命周期以及关注spring bean对象的后置处理器:BeanPostProcessor(一个接口)

    Spring IOC 容器对 Bean 的生命周期进行管理的过程: 1.通过构造器或工厂方法创建 Bean 实例 2.为 Bean 的属性设置值和对其他 Bean 的引用 3.将 Bean 实例传递给 ...

  6. What is Pay Me to Learn——Google Summer of Code 2013

    原文链接:http://zhchbin.github.io/2013/10/17/what-is-pay-me-to-learn/ 背景 今天早上才想起来,自己还欠着一件事情没有做完.很久在人人上之前 ...

  7. grunt管理js/css

    1.安装node 2.npm安装 3.运行grunt,可能遇到下面的问题 可以运行npm install -g grunt 然后再运行grunt 可以看到已经压缩成功了:

  8. net 串口通讯 网口通讯(Socket)

    1.串口通讯 2.网口(Socket) 源码下载:源码附件

  9. c#获取word文件页数、字数

    引用命名空间:using Microsoft.Office.Interop.Word; //启动Word程序 Application myWordApp = new ApplicationClass( ...

  10. SHT20 IIC总线驱动概述

    SHT20温湿度传感器使用iic总线的驱动方式,以下资料参考SHT20 datasheet总结 1.IIC总线 Start信号 IIC总线的起始信号以SDA由高电平变为低电平,等待5us以上,再由SC ...