-3

This is a simple password app, and it's not really working, i'm not sure what most of this sentences mean. I have some knowledge in c++ but this is new to me. Can somebody correct me? I can't find a site that explains this well.

        public void addListenerOnButton(){

    geslo = (EditText) findViewById(R.id.password);
    Gumb  = (Button) findViewById(R.id.Gump);

    Gumb.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        String text="banana";
        if(geslo.toString()==text){
            Intent newactivity= new Intent(MyActivity.this,MainDatoteka.class);
            startActivity(newactivity);
        }
        }
    });
}    
user3617642
  • 27
  • 1
  • 7
  • `i'm not sure what most of this sentences mean` so where have you copied it from? Btw: `geslo.toString()==text` should be `geslo.getText().toString().equals(text)`. – Tom Oct 29 '14 at 11:46

2 Answers2

3

2 errors : you don't compare String with ==, and you have to use getText() on the EditText component :

if(geslo.getText().toString().equals(text))
ToYonos
  • 16,469
  • 2
  • 54
  • 70
1

use below code :-

if(geslo.getText().toString().equals(text))

instead of

if(geslo.toString()==text)
Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135
duggu
  • 37,851
  • 12
  • 116
  • 113