How to call setText() using a Float data type?

后端 未结 1 368
情歌与酒
情歌与酒 2021-01-13 07:29
    public void onClick(View v) {
    switch(v.getId()){
    case R.id.save2:
        s = text.getText().toString();
        number = Float.parseFloat(num.getText().         


        
相关标签:
1条回答
  • 2021-01-13 08:07

    If you pass a numeric value as the text to a text field, Android will try to interpret it as a resource Id. Make it a text first. The preferred way is to do:

    num.setText(String.valueOf(returnnum));
    

    (For good practices on conversion to string, check this post)

    0 讨论(0)
提交回复
热议问题