Hi I am making a logo quiz game and my if statement does not react to my input I made a textview and I pirnted out the input and it was yahoo (i entered yahoo in edit text and i declered if statement to check if it is yahoo)...
package com.example.logogame;
imports....
public class Yahoo extends Activity implements OnClickListener{
EditText et;
Button check;
TextView test;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.yahoo);
et = (EditText) findViewById(R.id.editTextAnswer);
check = (Button) findViewById(R.id.buttonCheck);
test = (TextView) findViewById(R.id.test);
check.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.buttonCheck:
String content = et.getText().toString();
//its always wrong here...
if(content == "yahoo"){
Toast toast = Toast.makeText(this, "Correct! Good work", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}else{
test.setText(content);
Toast toast = Toast.makeText(this, "Wrong...", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
break;
}
}