jeudi 7 janvier 2016

Java for android, if statement

I know this should be easy but i really don't know what i'm doing wrong.

I want to do somethin like this pseudocode:

if EditText = "ed" {show.mesage "Hi"}

else {hsow.messaje "NOPE"}

//--[Boton Sumar 2]--

                public void onBT_sumar2Click(View v) {

                    
                    EditText e1 = (EditText)findViewById(R.id.ET_1);
                    EditText e2 = (EditText)findViewById(R.id.ET_2);
                    TextView t1 = (TextView)findViewById(R.id.TV_resultado);


                    if (e1.getText().equals("ed")) {

                        //mensaje lol
                        Context context = getApplicationContext();
                        CharSequence text = ":V / hi :V /" ;
                        int duration = Toast.LENGTH_LONG;
                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();

                    }

                    else {
                        //mensaje lol
                        Context context = getApplicationContext();
                        CharSequence text = "NOPE"();
                        int duration = Toast.LENGTH_LONG;
                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();
                    }



                }

Aucun commentaire:

Enregistrer un commentaire