APP.java代码

package com.app.senior_calculator;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast; public class APP extends Activity { // 偏好设置
//private SharedPreferences sp;
//private SharedPreferences.Editor editor; /** level and mode (index) **/
int selectedLevelIndex = 0;
int selectedModeIndex = 0;
int chioceItems;
Bundle bundle = new Bundle(); /** choices **/
private String iconName1 = "选择难度";
private String[] arrayLevel = new String[] { "加减", "乘除", "四则运算(无括号)",
"四则运算(含括号)" };
private String iconName2 = "选择模式";
private String[] arrayModel = new String[] { "Practice", "Examination" };
/** 题目库 **/
private List<Question> source = new ArrayList<Question>(); public void onclick(View v) {
switch (v.getId()) {
case R.id.StartTest:
DialogDifficulty(arrayLevel, iconName1).show();
break;
case R.id.Medol:
DialogDifficulty(arrayModel, iconName2).show();
break;
case R.id.Help:
Toast.makeText(APP.this, " Dont know what to do……",
Toast.LENGTH_SHORT).show();
break;
case R.id.Exit:
Toast.makeText(APP.this, " Closing…………", Toast.LENGTH_SHORT).show();
finish();
break;
}
} /** 定义一个Dialog 展示 level选择 后者为标题 **/
public Dialog DialogDifficulty(final String[] array_data,
final String dialogtitle) {
chioceItems = selectedLevelIndex;
if (dialogtitle.equals("选择难度"))
chioceItems = selectedLevelIndex;
else if (dialogtitle.equals("选择模式"))
chioceItems = selectedModeIndex; Dialog alertDialog;
alertDialog = new AlertDialog.Builder(this, R.style.dialog)
.setTitle(dialogtitle)
.setIcon(R.drawable.diologicon)
.setSingleChoiceItems(array_data, chioceItems,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
if (dialogtitle.equals("选择难度"))
selectedLevelIndex = which;
else if (dialogtitle.equals("选择模式"))
selectedModeIndex = which;
/** 模式传递过去TestView根据模式来设置时间长度. */
bundle.putString("difficulty",
arrayModel[selectedModeIndex]);
}
})
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
bundle.putString("difficulty",
arrayModel[selectedModeIndex]);
/*
// 确定后保存数据模式跟难度的下标数据..
if (dialogtitle.equals("选择难度"))
editor.putInt("selectedLevelIndex", which); if (dialogtitle.equals("选择模式"))
editor.putInt("selectedModeIndex", which); editor.commit();// 提交修改
*/
/** 在确定难度后跳转出题目 设置模式到时候不跳转. **/
if (dialogtitle.equals("选择难度"))
createexercise();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 实现函数- 。- 调用.
Toast.makeText(APP.this, " canceling ",
Toast.LENGTH_SHORT).show();
}
}).create();
return alertDialog;
} /** 出题模块 根据选择的模式出先不同数量的题目. **/
public void createexercise() {
int totalNumber = 50;
if (arrayModel[selectedModeIndex].equals("Examination"))
totalNumber = 25;
switch (selectedLevelIndex) {
case 0:
source = new ArrayList<Question>();
Toast.makeText(APP.this, String.valueOf(selectedLevelIndex), Toast.LENGTH_LONG)
.show();
new SimpleCreate().simpleExerciseInitation(0, totalNumber, source);
for (int i = 0; i < source.size(); i++)
Log.i("info", source.get(i).getExercise() + "="
+ source.get(i).getAnswer());
bundle.putSerializable("resource", (Serializable) source);
Intent MAintent = new Intent(APP.this, TestView.class);
MAintent.putExtras(bundle);
startActivity(MAintent);
break;
case 1:
source = new ArrayList<Question>();
new SimpleCreate().simpleExerciseInitation(1, totalNumber, source);
for (int i = 0; i < source.size(); i++)
Log.i("info", source.get(i).getExercise() + "="
+ source.get(i).getAnswer());
bundle.putSerializable("resource", (Serializable) source);
Intent intent1 = new Intent(APP.this, TestView.class);
intent1.putExtras(bundle);
startActivity(intent1);
break; case 2:
source = new ArrayList<Question>();
new MidiumCreate().midiumCreateInitation(totalNumber, source);
for (int i = 0; i < source.size(); i++)
Log.i("info", source.get(i).getExercise() + "="
+ source.get(i).getAnswer());
bundle.putSerializable("resource", (Serializable) source);
Intent intent2 = new Intent(APP.this, TestView.class);
intent2.putExtras(bundle);
startActivity(intent2);
break;
case 3:
source = new ArrayList<Question>();
// 出题目验证.
new CreateEFraction().createYouExercisess(totalNumber, source);
for (int i = 0; i < source.size(); i++)
Log.i("info", source.get(i).getExercise() + "="
+ source.get(i).getAnswer());
bundle.putSerializable("resource", (Serializable) source);
Intent intent3 = new Intent(APP.this, TestView.class);
intent3.putExtras(bundle);
startActivity(intent3);
break;
default:
Toast.makeText(APP.this, "errors happend ", Toast.LENGTH_LONG)
.show();
break;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.app);
/*// 获取偏好设置实例
sp = getSharedPreferences("MySP", MODE_PRIVATE);
editor = sp.edit();
editor.putInt("selectedLevelIndex",0);
editor.putInt("selectedModeIndex", 0);
editor.commit();// 提交修改
*/ } }

第三个Sprint ------第七天的更多相关文章

  1. “数学口袋精灵”App的第三个Sprint计划----开发日记(第一天12.7~第十天12.16)

    “数学口袋精灵”第三个Sprint计划----第一天 项目进度: 基本完成一个小游戏,游戏具有:随机产生算式,判断对错功能.通过轻快的背景音乐,音效,给玩家提供一个良好的氛围.  任务分配: 冯美欣: ...

  2. Lucene.Net 2.3.1开发介绍 —— 三、索引(七)

    原文:Lucene.Net 2.3.1开发介绍 -- 三.索引(七) 5.IndexWriter 索引这部分最后讲的是IndexWriter.如果说前面提到的都是数据的结构,那么IndexWriter ...

  3. “数学口袋精灵”App的第三个Sprint计划(总结与团队感悟)----开发日记

    第三阶段Sprint完成情况: 我们的"数学口袋精灵"App已经完成了,该app能随机产生多种形式的算式,比如带括号的,分数四则运算,混合运算,阶乘等,通过游戏形式让用户乐在其中. ...

  4. “数学口袋精灵”App的第三个Sprint计划----开发日记(第十一天12.17)

    项目进度: 基本完成一个小游戏,游戏具有:随机产生算式,判断对错功能.通过轻快的背景音乐,音效,给玩家提供一个良好的氛围.  任务分配: 冯美欣:设计"数学口袋精灵"App图标.整 ...

  5. 第三个Sprint冲刺总结

    第三个Sprint冲刺总结 1.燃尽图 2.本阶段总结: 本阶段主要是对产品进行完善和美化,所以工作量不是很多.但要做精,做好并非是一件简单的事情.我们各组员都安排了各自的任务,如参考各行业的优秀ap ...

  6. 第三个Sprint冲刺第七天

    讨论地点:宿舍 讨论成员:邵家文.李新.朱浩龙.陈俊金 讨论问题:做最后的工作

  7. 第三个Sprint冲刺第七天(燃尽图)

  8. 数据结构(三) 用java实现七种排序算法。

    很多时候,听别人在讨论快速排序,选择排序,冒泡排序等,都觉得很牛逼,心想,卧槽,排序也分那么多种,就觉得别人很牛逼呀,其实不然,当我们自己去了解学习后发现,并没有想象中那么难,今天就一起总结一下各种排 ...

  9. 第三个Sprint ------第十一天

    四则运算APP推广: 1通过微信公众平台推广APP,写一片软文,然后推送出去.分享朋友圈.QQ空间. 2通过微博推广APP,@各微博大户. 3让之前内侧的同学转发给自己的小弟小妹或者侄女侄子! 总结: ...

随机推荐

  1. 使用if语句时应注意的问题(初学者)

    (1)在三种形式的if语句中,在if关键字之后均为表达式.该表达式通常是逻辑表达式或关系表达式,但也可以是其他表达式,如赋值表达式等,甚至也可以是一个变量. 例:if(a=5)语句: if(b)语句: ...

  2. 【美妙的Python之三】Python 对象解析

    美妙的Python之Python对象         简而言之: Python 是能你无限惊喜的语言.与众不同.         Python对象概念的理解,是理解Python数据存储的前提.Pyth ...

  3. 检測iPhone/iPad设备方向的三种方法

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/iefreer/article/details/24210391 使用meta tag "v ...

  4. 阿里巴巴android开发手册总结

    每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code 1  2. 3. 4. 5. 6. 7.   8. 9  每天学习一点点 编程PDF电子书免费 ...

  5. linux(centos 7)下安装elasticsearch - head插件(端口占用,防火墙关闭)

    本文章来自网络仅供个人学习记录之用 一:安装Git(如果未安装) 1, yum install git 2, git --version #查看版本 二:安装node(如果未安装) node安装 三: ...

  6. WIN10刚开机任务管理显示CPU占用100%问题

    针对WIN10更新后出现的问题!!! 现象: 电脑刚开机,直接打开任务管理器,CPU占用100%! 但是电脑运行速度正常,按道理这时候应该卡死!(排除病毒) 下载鲁大师查看只是显示CPU 3%!而网上 ...

  7. ucml JS调用其它页面上的服务端方法

    var params = { _bpoName: "BPO_KH_ED" + "Service", //BPO的名字(拥有那个服务端函数的BPO) _metho ...

  8. OpenCV——轮廓填充drawContours函数解析

    函数的调用形式 void drawContours(InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const ...

  9. 一、java虚拟机内存区域

    内存区域 java虚拟机在java程序的过程中会把它所管理的内存划分为若干个不同的数据区域.java虚拟机规范将JVM管理的内存分为:程序计数器.本地方法栈.Java虚拟机栈.方法区.Java堆.如下 ...

  10. VS2017上执行VS2013项目错误MSB802之解决方案

    进行想把我编写的数字图像处理软件MagicHouse更新到最新的VS2017开发环境下,原来的开发环境是VS2013.但是用VS2017打开项目并编译时,系统报错误MSB802,如下图所示. 其实Vi ...