小编som*_*smc的帖子

将编辑文本转换为双重android

我有2个编辑文本,因为我想让它们成为小数,我不能使它们成为整数,所以我必须将它们变成双精度.我有这个代码,但在n2Var获取文本我有一个错误.

    mul = (Button) findViewById(R.id.button);
    n1 = (EditText)findViewById(R.id.editText);
    n2 = (EditText)findViewById(R.id.editText2);
    ans = (EditText)findViewById(R.id.TextView10);

    double n1Var = Double.parseDouble(n1.getText().toString());
    double n2Var = Double.parseDouble(n2,getText().toString());
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!

double int android android-edittext

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

android-edittext ×1

double ×1

int ×1