我想将两个变量从一个屏幕传递给另一个。从之前的筛选器中,单击一个按钮,1或2并将其传递给该筛选器。它也传递值2作为正确的值。我知道他们都在工作,因为我在下一个屏幕上输出每个变量。这是代码。但它始终输出错误。简单如果声明
Intent i = getIntent();
Bundle b = i.getExtras();
String newText = b.getString("PICKED");
String correct = b.getString("CORRECT");
TextView titles = (TextView)findViewById(R.id.TextView01);
if(newText == correct){
titles.setText("Correct" + newText + " " + correct + "");
}
else{
titles.setText("Wrong" + newText + " " + correct + "");
}
http://stackoverflow.com/questions/513832/how-do-i-compare-strings- in-java – kloffy 2011-02-13 17:06:06