java.lang.NumberFormatException:无效的double:""?

时间:2015-09-17 22:44:21

标签: string text double tostring gettext

我不确定如何解决这个问题。 我有一个旋转器。当选择某个选项时,文本字段(数字)中的任何内容我都希望将该值用于特定方法。

在Main:

EditText temp;
temp = (EditText)findViewById(R.id.editText);



public void onItemSelected(AdapterView<?> parent, View view, int position, long id) 
{

String choice = parent.getSelectedItem().toString();
Double value = Double.parseDouble(temp.getText().toString());
}

在尝试将temp转换为double之前,一切正常,它会使应用程序崩溃。任何帮助将不胜感激。

我是ANDROID STUDIO的新手。

1 个答案:

答案 0 :(得分:0)

我认为temp字段是空的(因此是“”),它不能很好地解析为double。

相关问题