Here I am trying to get txt from EditText field , and compare it with another string that I defined in the code, after the compare done I am gonna show some messages that sys " they are equal " just I wann use it for another purpose. I tried this code it prints what I write in the EditTex into TextView. but it did not compare i what I type in they r equal or not. Plz help
final Button btntx = (Button)findViewById(R.id.btn1);
final EditText edittxt1 = (EditText)findViewById(R.id.edttxt);
final TextView messageshow= (TextView)findViewById(R.id.txtview);
btntx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button b= (Button)v;
String data= edittxt1.getText().toString();
String takefromtost= "Turn on";
messageshow.setText(" " + data);
if (data=="Turn on")
{
Toast.makeText(getBaseContext(),"They are equal", Toast.LENGTH_SHORT).show();
messageshow.setText("They are equal");
}
}
});