- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我今天一直在开发这个应用程序,但我似乎无法弄清楚代码有什么问题。
当我检查时,没有语法错误。但是当我尝试运行它并调试它时,它说
“ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent)”行上的“找不到源”:2106
它让我可以选择另一条路径,但唯一可用的是默认设置。我编码错了吗?我该怎么做才能解决这个问题?
这是日志:
12-20 22:12:29.722: I/System.out(1518): debugger has settled (1479)
12-20 22:12:30.172: W/Trace(1518): Unexpected value from nativeGetEnabledTags: 0
12-20 22:12:30.222: W/Trace(1518): Unexpected value from nativeGetEnabledTags: 0
这是我的源文件:
package com.example.rockpaperscissorlizardspock;
import java.util.Random;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.view.View.OnClickListener;
public class rockpaperscissorlizardspock extends Activity {
/** Called when the activity is first created. */
private TextView resultText;
private Button play, reset;
private ImageButton scissors, paper, rock, lizard, spock;
private int paperimg, paper_pressedimg, scissorsimg, scissors_pressedimg, rockimg, rock_pressedimg, lizardimg, lizard_pressedimg, spockimg, spock_pressedimg;
private ImageView compSciss, compPaper, compRock, compLiz, compSpock;
Random rand = new Random();
int compChoice = 0;
String pChoice ="";
String cChoice = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Initialize();
}
/** initialize all of the components*/
private void Initialize()
{
play = (Button) findViewById(R.id.button1);
reset = (Button) findViewById(R.id.button2);
resultText = (TextView) findViewById(R.id.resultText);
lizard = (ImageButton) findViewById(R.id.imageButton4);
spock = (ImageButton) findViewById(R.id.imageButton5);
scissors = (ImageButton) findViewById(R.id.imageButton3);
paper = (ImageButton) findViewById(R.id.imageButton2);
rock = (ImageButton) findViewById(R.id.imageButton1);
compSciss = (ImageView) findViewById(R.id.computerScissors);
compPaper = (ImageView) findViewById(R.id.computerPaper);
compRock = (ImageView) findViewById(R.id.computerRock);
spockimg = R.raw.spock;
spock_pressedimg = R.raw.spock_pressed;
lizardimg = R.raw.lizard;
lizard_pressedimg = R.raw.lizard_pressed;
paperimg = R.raw.paper;
paper_pressedimg = R.raw.paper_pressed;
scissorsimg = R.raw.scissors;
scissors_pressedimg = R.raw.scissors_pressed;
rockimg = R.raw.rock1;
rock_pressedimg = R.raw.rock1_pressed;
/**set the button Listeners*/
play.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
play();
}
});
reset.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
paper.setImageResource(paperimg);
rock.setImageResource(rockimg);
scissors.setImageResource(scissorsimg);
lizard.setImageResource(lizardimg);
spock.setImageResource(spockimg);
compPaper.setImageResource(paperimg);
compRock.setImageResource(rockimg);
compSciss.setImageResource(scissorsimg);
compLiz.setImageResource(lizardimg);
compSpock.setImageResource (spockimg);
pChoice = "";
cChoice = "";
play.setEnabled(false);
reset.setEnabled(true);
scissors.setEnabled(true);
paper.setEnabled(true);
rock.setEnabled(true);
lizard.setEnabled(true);
spock.setEnabled(true);
resultText.setText("");
}
});
/*
* Declaring what happens when specific choices are made.
*/
scissors.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
scissors.setImageResource(scissors_pressedimg);
paper.setImageResource(paperimg);
rock.setImageResource(rockimg);
spock.setImageResource(spockimg);
lizard.setImageResource(lizardimg);
pChoice = "S";
play.setEnabled(true);
}
});
paper.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
paper.setImageResource(paper_pressedimg);
scissors.setImageResource(scissorsimg);
spock.setImageResource(spockimg);
rock.setImageResource(rockimg);
lizard.setImageResource(lizardimg);
pChoice = "P";
play.setEnabled(true);
}
});
rock.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
rock.setImageResource(rock_pressedimg);
scissors.setImageResource(scissorsimg);
paper.setImageResource(paperimg);
spock.setImageResource(spockimg);
lizard.setImageResource(lizardimg);
pChoice = "R";
play.setEnabled(true);
}
});
lizard.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
lizard.setImageResource(lizard_pressedimg);
spock.setImageResource(spockimg);
rock.setImageResource(rockimg);
scissors.setImageResource(scissorsimg);
paper.setImageResource(paperimg);
pChoice = "L";
play.setEnabled(true);
}
});
spock.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
spock.setImageResource(spock_pressedimg);
lizard.setImageResource(lizardimg);
rock.setImageResource(rockimg);
scissors.setImageResource(scissorsimg);
paper.setImageResource(paperimg);
pChoice = "SP";
play.setEnabled(true);
}
});
}
/**The method that chooses the computer's move and compares
* to the player's move.
*/
public void play()
{
compChoice = rand.nextInt(5);
if(compChoice == 0)
{
cChoice = "R";
compRock.setImageResource(rock_pressedimg);
}
else if(compChoice == 1){
cChoice = "P";
compPaper.setImageResource(paper_pressedimg);
}
else if(compChoice == 2)
{
cChoice = "S";
compSciss.setImageResource(scissors_pressedimg);
}
else if(compChoice == 3)
{
cChoice = "L";
compLiz.setImageResource(lizard_pressedimg);
}
else if(compChoice == 4)
{
cChoice = "SP";
compSpock.setImageResource(spock_pressedimg);
}
check();
}
/**
* Compares the Computer's and the Player's moves.
*/
public void check()
{
if(pChoice == "R") //Rock
{
if(cChoice == "R")
resultText.setText("Draw");
else if(cChoice == "P")
resultText.setText("You Lose");
else if(cChoice == "S")
resultText.setText("You Win");
else if(cChoice == "L")
resultText.setText("You Win");
else if(cChoice == "SP")
resultText.setText("You Lose");
}
else if(pChoice == "P") //Paper
{
if(cChoice == "R")
resultText.setText("You Win");
else if(cChoice == "P")
resultText.setText("Draw");
else if(cChoice == "S")
resultText.setText("You Lose");
else if(cChoice == "SP")
resultText.setText("You Win");
else if(cChoice == "L")
resultText.setText("You Lose");
}
else if(pChoice == "S") //Scissors
{
if(cChoice == "R")
resultText.setText("You Lose");
else if(cChoice == "P")
resultText.setText("You Win");
else if(cChoice == "S")
resultText.setText("Draw");
else if(cChoice == "L")
resultText.setText("You Win");
else if(cChoice == "SP")
resultText.setText("You Lose");
}
else if(pChoice == "L") //Lizard
{
if(cChoice == "R")
resultText.setText("You Lose");
else if(cChoice == "L")
resultText.setText("Draw");
else if(cChoice == "SP")
resultText.setText("You Win");
else if(cChoice == "S")
resultText.setText("You Lose");
else if(cChoice == "P")
resultText.setText("You Win");
}
else if(pChoice == "SP") //Spock
{
if(cChoice == "SP")
resultText.setText("Draw");
else if(cChoice == "L")
resultText.setText("You Lose");
else if(cChoice == "S")
resultText.setText("You Win");
else if(cChoice == "P")
resultText.setText("You Lose");
else if(cChoice == "R")
resultText.setText("You Win");
}
gameOver();
}
/**
* Runs at the end of each round. Disables all of the buttons
* except for the reset button.
*/
public void gameOver()
{
play.setEnabled(false);
scissors.setEnabled(false);
rock.setEnabled(false);
paper.setEnabled(false);
spock.setEnabled(false);
lizard.setEnabled(false);
reset.setEnabled(true);
}
最佳答案
您已尝试单步进入 ActivityThread
类。 SDK 中没有此类的源代码。所以总之没有错。
关于android - 石头,布,剪刀,蜥蜴,史波克 Android 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13981183/
这是我的问题 1)我有动态y数组数据,使用该数组如何连续绘制波浪。 如果Y数组数据完整,则使用相同的y数组数据继续。 2)声音自动播放在该数组值是143.if我停止不停止。 这是我的代码:
网络上有太多使用 WiFi 或蓝牙传输数据的对讲机应用程序(至少我见过的所有应用程序),但没有一个使用内置天线通过 radio 波传输数据真正的对讲机设备。 是否有任何安全原因?还是限制作为发送器/接
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve this
我正在尝试着手研究 boost wave,但到目前为止,我的运气并不好。 我尝试了网站上的示例代码。如下: #include #include #include #include #inclu
我正在尝试使用 svg 编写一个 javascript 加载器。想法是,它是一个从下到上两侧均匀填充的圆圈,加载器的顶线是一个从左到右不断移动的正弦波。 我能够根据百分比为加载程序创建弧线,如下所示:
这个问题在这里已经有了答案: Is there a one-line function that generates a triangle wave? (8 个答案) 关闭 9 年前。 我试图用 A
当我在论坛中搜索时,我了解到要定位 GPS,我必须通过互联网连接或短信发送坐标。但据我所知,我们可以通过 radio 波进行通信,发送语音、图片、数据。我可以用它来获取数据吗? GPS 设备?因为业余
我是一名优秀的程序员,十分优秀!