jeudi 25 juin 2015

how to solve the incompatible when using IF ELSE statement in Android studio?

when I created the the (EditText) fields a , b and c ,I let it's type as a number (android:inputType="number"), then when I tried to write the following code I got a hint told me that there is an incompatible .

    button.setOnClickListener(new View.OnClickListener() {
                          @Override
            public void onClick(View v) {

             if(!"".equals(a.getText())
             &&!"".equals(b.getText())
             &&!"".equals(c.getText())) {

                              double a1 = Double.parseDouble(a.getText().toString());
                              double b1 = Double.parseDouble(b.getText().toString());
                              double c1 = Double.parseDouble(c.getText().toString());

                              Double r = b1 * c1 / a1;
                              result.setText(r.toString());
                          }

                          else{
                                  Toast.makeText(MainActivity.this,"Not A Real Value",Toast.LENGTH_SHORT).show();
                              }

                          }
        });

Aucun commentaire:

Enregistrer un commentaire