我的问题是如何在单击按钮后显示新图像,但条件来自其他类。我是这里的新手,我想知道如何将班级与其他班级联系起来。我尝试了意图...
这是我的代码
这是我们问题的课程......
@Override
// TODO Auto-generated method stub
public void onClick(View v) {
String answer = "Marianas Trench";
String answer2 = "marianas trench";
String answer3 = "MARIANAS TRENCH";
String check = input.getText().toString();
if (check.contentEquals(answer)){
tvresult.setText("Correct");
Intent myIntent= new Intent("com.turtleexploration.LEVEL1");
startActivity(myIntent);
}else if (check.contentEquals(answer2)){
tvresult.setText("Correct");
Intent myIntent= new Intent("com.turtleexploration.LEVEL1");
startActivity(myIntent);
}else if (check.contentEquals(answer3)){
tvresult.setText("Correct");
Intent myIntent = new Intent("com.turtleexploration.LEVEL1");
startActivity(myIntent);
}else{
tvresult.setText("Wrong");
}
Intent intObj = new Intent(Question.this, Level1.class);
intObj.putExtra("ANSWER", answer);
startActivity(intObj);
}
这是问题选择类..
ImageButton l1 = (ImageButton) findViewById(R.id.l1);
TextView t1 = (TextView) findViewById(R.id.t1);
Intent intename = getIntent();
String mainans = "Marianas Trench";
String ans = (String) intename.getSerializableExtra("ANSWER");
if (ans == mainans){
l1.getBackground().equals(getResources().getDrawable(R.drawable.m1));
t1.setText("Correct");
}else{
}
该按钮位于问题选择菜单中...