lundi 27 avril 2015

android-if condition doesn't work

I have an android application and I have two EditText's .. the user input Distance and Time ... I made an if statement to show an error message if the user didn't insert one of the two values

            String strDistance,strTime;
            strDistance=edtDistance.getText().toString();
            strTime=edtTime.getText().toString();


            if(strDistance==null||strTime==null){


              txtError.setText("Please insert the distance and time");



        }


            else{

                calculateLogic();
                app.setFare(fare);

                Intent intent=new Intent(MainActivity.this,Fare.class);
                startActivity(intent);


            }

now it works fine only if I inserted the two values .... but when I insert only one of them or non of them the application stops working and don't show the error message in the else statement.

Aucun commentaire:

Enregistrer un commentaire