i have an login screen where i have a username. if the username is "z" my programe shpould go in the if statement but it always goes in the else. i try always to write z on username but he is always sending me fail. where is the fault ? i mean before the statement i have some system outs who give out the correct strings in the username edittext...
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends FragmentActivity {
// Fragment TabHost as mTabHost
EditText text;
Button login;
EditText password;
String username;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (EditText) findViewById(R.id.editText);
login = (Button) findViewById(R.id.button);
password = (EditText) findViewById(R.id.editText2);
login.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
username =text.getText().toString();
System.out.println(text.getText().toString());
System.out.println(password.getText().toString());
if(username =="z" ){
System.out.println("success");
}else{
System.out.println("Fail");
}
}
});
}
}
Aucun commentaire:
Enregistrer un commentaire