手机打字测速软件简版
来源:互联网 发布:oracle12c数据库安装 编辑:程序博客网 时间:2024/05/19 02:45
写了个测速软件,有什么不足的地方还望指教,我是个菜鸟
package com.example.typespeed;
import java.util.Random;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity{
public static int time = 60;
private TextView textShow;
private TextView timeShow;
private int scoreChar = 0;
private EditText inPut;
char[] c = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
'r','s','t','u','v','w','x','y','z'};
private Random random = new Random();
private int i = 0;
private Handler handler = new Handler(){
public void handleMessage(Message msg) {
int t = msg.what;
timeShow.setText(t+"");
if (t==0) {
score();
}
}
};
private Runnable runnable = new Runnable() {
public void run() {
time--;
if (time>=0) {
handler.postDelayed(runnable, 1000);
}else {
return;
}
Message message = new Message();
message.what = time;
handler.sendMessage(message);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textShow = (TextView)this.findViewById(R.id.textShow);
inPut = (EditText)this.findViewById(R.id.edText);
timeShow = (TextView)findViewById(R.id.timeShow);
timeShow.setText(60+"");
i = random.nextInt(25);
textShow.setText(c[i]+"");
}
//计算得分
public void score(){
double scores = scoreChar/60;
Toast.makeText(this, "您的得分是:"+scoreChar, Toast.LENGTH_LONG).show();
}
int ac = 0;
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
time = 60;
inPut.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String tString = textShow.getText()+"";
if (/*tString.equals(inPut.getText()+"")*/
inPut.getText().length()>=1) {
i = random.nextInt(25);
textShow.setText(c[i]+"");
if (tString.equals(inPut.getText()+"")) {
scoreChar++;
}
inPut.setText("");
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
//启动线程计时
if (ac == 0) {
handler.post(runnable);
time = 60;
Log.i("jinchengyunxing", time+"|");
ac++;
}
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
/*if (inPut.getText()!=null) {
inPut.setText("");
}*/
}
});
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
Log.v("ddd", "onPause");
time = -1;
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
Log.v("ddd", "onStop");
time = -1;
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
- 手机打字测速软件简版
- 在线打字测速系统
- 打字速度第一次测速--很烂呐
- 网络测速软件IPERF
- iperf网络测速软件
- swustoj手机打字(1185)
- 中彩分析家 打字软件
- c#打字小软件
- 模拟打字软件
- ubuntu12.04打字软件
- 测速
- 测速
- 测速
- 测速
- linux测速软件的使用 iperf
- 局域网测速软件 iperf 的简要使用方法
- 中国cad工程 打字软件
- 网络打字软件使用教程。
- C++:关于class member声明为static的情况
- Cocos2d-x3.0自己写的项目编译笔记
- 记录自己的第一个上线项目
- PowerPCB gerber out时*.rep,*.pho,*.drl,*.lst各表示什么意思,在制板时哪些文件是制板商所需要的?
- PAT A 1079. Total Sales of Supply Chain (25)
- 手机打字测速软件简版
- 十四周项目三
- C语言获取文件大小
- 14-2-形状类族的中的纯虚函数(OJ版)
- 长颈鹿类对动物类的私有继承及保护继承 找错
- 托管 WCF 服务
- Linux GTK 打砖块 最新版
- 背单词小技巧,大效果
- 实现类似于ajax的页面无刷新