我想將兩個變量從一個屏幕傳遞給另一個。從之前的篩選器中,單擊一個按鈕,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