Converting String to Double in Android

前端 未结 8 676
感情败类
感情败类 2020-12-09 02:29

Trying to get double values from an EditText and manipulate them before passing them to another Intent. Not using primitive data type so I can use toString methods.

8条回答
  •  甜味超标
    2020-12-09 03:09

      kw=(EditText)findViewById(R.id.kw);
        btn=(Button)findViewById(R.id.btn);
        cost=(TextView )findViewById(R.id.cost);
    
    
                btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) { cst =  Double.valueOf(kw.getText().toString());
                cst = cst*0.551;
                cost.setText(cst.toString());
            }
        });
    

提交回复
热议问题