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. day14 Python集合的补充

    python_1 = ['charon','pluto','ran','charon'] linux_1 = ['ran','xuexue','ting'] p_s = set(python_1) l ...

  2. VsCode之使用WebView通信

    之前我在这篇文章VsCode插件开发之插件初步通信 通过插件完成通信,这回我还是通过插件,只不过方式主要以在ts文件里面使用webview来进行通信. 另外在此声明,一定要好好看仔细看官方文档,国内关 ...

  3. warning: ISO C++ forbids converting a string constant to 'char*'

    第1种字符串赋值方式: char * fileName="./2017-09-02-10-34-10.xml";//这一种字符串赋值方式已经被ISO禁止了 第2种字符串赋值方式: ...

  4. nodeJS---URL相关模块用法(url和querystring)

    nodeJS---URL相关模块用法(url和querystring) 一: URL模块: URL模块用于解析和处理URL的字符串,提供了如下三个方法: 1. parse 2. format 3. r ...

  5. ztree树形菜单demo

    阅读目录 zTree树形菜单 回到顶部 zTree树形菜单 树形菜单使用方式如下:HTML引入的方式如下: <!DOCTYPE html> <html> <head> ...

  6. VUE2第五天学习---自定义指令

    阅读目录 1.理解VUE中的自定义指令 回到顶部 1.理解VUE中的自定义指令 默认核心指令有 (v-model 和 v-show), 但是有时候我们需要用到自定义指令,在vue中,代码复用主要形式和 ...

  7. CVE-2016-7912 分析报告

    CVE-2016-7912 背景介绍 在内核USB驱动中,进行异步读取或写入时,调用ki_complete(),会提前释放kiocb结构体,从而造成UAF漏洞,但经过分析,发现无法利用此漏洞进行攻击. ...

  8. 大功率DC-DC方案

    三端稳压芯片只适合于小功率器件的直流稳压(电流<1A):如7805,这个电路是可以应付大多数情况的: 如果出现大功率的器件就需要采用新的稳压方案,可以参考下图方案: https://www.bi ...

  9. keystore

    p12转keystorekeytool -v -importkeystore -srckeystore temp.p12 -srcstoretype PKCS12 -destkeystore temp ...

  10. Maven私有仓库: 发布release版本报错:Return code is: 400, ReasonPhrase: Repository does not allow upd ating assets: maven-releases.

    今天在将一个maven组件由SNAPSHORT升级为正式版本1.0.0,然后执行发布: mvn clean deploy -pl ielong-common -am -DskipTests, 报错:R ...