• 大小: 51KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Java
  • 标签: android  

资源简介

基于android平台的猜数字游戏(源代码+详尽的注释)即使是新手相信也会容易理解!希望能够帮助菜鸟进阶!!!

资源截图

代码片段和文件信息

package net.xsmile.guess;

import net.xsmile.guessNumber.NewGuess;
import net.xsmile.guessNumber.NumberGuess;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.onclickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;


public class Guess extends Activity {
private TextView playerNamechancenumberresultsend;
private Button guess;
private LinearLayout layout1layout2;
private String pName;
private int level;
private NumberGuess newGuess;


public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
              
        playerName=(TextView)findViewById(R.id.name);
        chance=(TextView)findViewById(R.id.left);
        number=(TextView)findViewById(R.id.number);
        number.setSelectAllonfocus(true);
        results=(TextView)findViewById(R.id.results);
        end=(TextView)findViewById(R.id.end);
        guess=(Button)findViewById(R.id.guess);
        layout1=(LinearLayout)findViewById(R.id.label1);
        layout2=(LinearLayout)findViewById(R.id.label2);
        
        SharedPreferences preferences = getSharedPreferences(“NewGuess“ 0);
        pName=preferences.getString(“name““John Do“);
        level=preferences.getInt(“level“ 9);
        newGuess=new NewGuess(level);

        playerName.setText(pName);
        chance.setText(Integer.toString(level));
        //add Listener
        guess.setonclickListener(play);
        
        
        
    
    }

private onclickListener play=new onclickListener(){
public void onclick(View v){
String gnumber=number.getText().toString();
guess.requestFocus();
number.requestFocus();
if(gnumber.length()<4){
showAlert(getString(R.string.alert_title) 1 getString(R.string.alert_length)getString(R.string.alert_button)true);
}else if(!newGuess.isNumberValid(gnumber)){
showAlert(getString(R.string.alert_title) 1 getString(R.string.alert_unique)getString(R.string.alert_button)true);
}
else{
switch(newGuess.NumberCompare(gnumber)){
case 1:{
layout1.setVisibility(8);
layout2.setVisibility(8);
end.setText(getString(R.string.success));
break;
}
case 0:{
layout1.setVisibility(8);
layout2.setVisibility(8);
end.setText(getString(R.string.failure)+(newGuess.getNewNumber().toString()));
break;
}
case 2:{
chance.setText(Integer.toString(newGuess.getGuessTimeLeft()));
}
}
results.setText(newGuess.getResults().toString());
}
}
};








}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        265  2008-04-16 09:23  MobileGuess\.classpath

     文件       1287  2008-04-16 09:23  MobileGuess\.project

     文件        629  2008-04-16 09:36  MobileGuess\AndroidManifest.xml

     目录          0  2008-09-06 18:47  MobileGuess\assets

     文件      13276  2008-04-23 12:23  MobileGuess\bin\classes.dex

     文件      22952  2008-04-23 12:23  MobileGuess\bin\MobileGuess.apk

     文件       2640  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\Guess$1.class

     文件       3003  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\Guess.class

     文件       2506  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\MobileGuess$1.class

     文件       2043  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\MobileGuess.class

     文件        334  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R$attr.class

     文件        394  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R$drawable.class

     文件        753  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R$id.class

     文件        417  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R$layout.class

     文件        951  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R$string.class

     文件        517  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guess\R.class

     目录          0  2008-09-06 18:47  MobileGuess\bin\net\xsmile\guess

     文件       3456  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guessNumber\NewGuess.class

     文件        391  2008-04-23 12:23  MobileGuess\bin\net\xsmile\guessNumber\NumberGuess.class

     目录          0  2008-09-06 18:47  MobileGuess\bin\net\xsmile\guessNumber

     目录          0  2008-09-06 18:47  MobileGuess\bin\net\xsmile

     目录          0  2008-09-06 18:47  MobileGuess\bin\net

     文件      17733  2008-04-23 12:23  MobileGuess\bin\resources.ap_

     目录          0  2008-09-06 18:47  MobileGuess\bin

     文件       6094  2007-12-13 19:38  MobileGuess\res\drawable\icon.png

     目录          0  2008-09-06 18:47  MobileGuess\res\drawable

     文件       1849  2008-04-16 09:41  MobileGuess\res\layout\login.xml

     文件       2415  2008-04-16 09:41  MobileGuess\res\layout\main.xml

     目录          0  2008-09-06 18:47  MobileGuess\res\layout

     文件       1102  2007-12-15 23:08  MobileGuess\res\values\strings.xml

............此处省略16个文件信息

评论

共有 条评论