這是代碼力...我的項目總是執行關閉
這是一個主要的問題是給.. 包com.turtle第一類;
import com.turtle.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
public class Question extends Activity{
protected static final String Level1 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.question);
Button chkButton = (Button) findViewById(R.id.bresult);
final EditText input = (EditText) findViewById(R.id.etext);
final TextView tvresult = (TextView) findViewById(R.id.tvresult2);
chkButton.setOnClickListener(new View.OnClickListener() {
@Override
// TODO Auto-generated method stub
public void onClick(View v) {
String answer = "Marianas Trench";
String answer2 = "marianas trench";
String answer3 = "MARIANAS TRENCH";
Bundle b = new Bundle();
b.putString("ANSWER", answer);
String check = input.getText().toString();
if (check.contentEquals(answer)){
b.putString("ANSWER", answer);
Intent intObj = new Intent(Question.this, Level1.class);
intObj.putExtras(b);
startActivity(intObj);
}else if (check.contentEquals(answer2)){
b.putString("ANSWER", answer);
Intent intObj = new Intent(Question.this, Level1.class);
intObj.putExtras(b);
startActivity(intObj);
}else if (check.contentEquals(answer3)){
b.putString("ANSWER", answer);
Intent intObj = new Intent(Question.this, Level1.class);
intObj.putExtras(b);
startActivity(intObj);
}else{
}
}
});
}
}
,這是它由圖像按鈕,如果點擊,就會進入到問題頁第二類....
package com.turtle;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
public class Level1 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.level1);
ImageButton btl1 = (ImageButton) findViewById(R.id.l1);
btl1.setOnClickListener (new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent= new Intent("com.turtleexploration.QUESTION");
startActivity(myIntent);
}
});
ImageButton btl2 = (ImageButton) findViewById(R.id.l2);
btl2.setOnClickListener (new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent= new Intent("com.turtleexploration.QUESTION2");
startActivity(myIntent);
}
});
ImageButton btBacklvl1 = (ImageButton) findViewById(R.id.backlvl1);
btBacklvl1.setOnClickListener (new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent= new Intent("com.turtleexploration.NEWGAME");
startActivity(myIntent);
}
});
}
}
你需要更清楚你的問題是什麼,症狀是什麼以及你試圖完成什麼。 – tmwoods 2013-03-02 17:52:27
好吧,我試圖完成一個問答遊戲,如果玩家是正確的..然後從一個類的按鈕圖像被改變..截至目前,我可以做到這一點,因爲許多錯誤...我嘗試過去幾周我所有的最好的,但即時通訊仍然是Android或java中的新手... – 2013-03-02 18:08:06
什麼錯了?你得到的錯誤是什麼? – cyroxx 2013-03-02 18:16:05