How to parse a double from EditText to TextView? (Android)

前端 未结 9 1198
时光取名叫无心
时光取名叫无心 2020-12-10 18:10

I\'m realy beginning to learn Java. When I run this code everything works fine till I leave my EditText boxes in the from empty and hit the run button. Then I get:

9条回答
  •  抹茶落季
    2020-12-10 18:26

    Another improvement:

    String thisIsIt = new Double(tvSumIn).toString();
    
    if(tvSumIn < 2){
        noSum.setText(thisIsIt + " This is it ");
    }else{
        noSum.setText("This is else");
    }
    

    could be:

    if(tvSumIn < 2){
        noSum.setText(tvSumIn + " This is it ");
    }else{
        noSum.setText("This is else");
    }
    

    Then you don't have to create a useless String

提交回复
热议问题