0

I'm not sure how to fix this problem. I have a spinner. When a certain choice is selected then whatever is in the text field (number) I want to use that value for a specific method.

In 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());
}

Everything works fine before I try to convert the temp into a double, it crashes the application. Any help will be appreciated.

I AM NEW TO ANDROID STUDIO.

Marcella Ruiz
  • 323
  • 1
  • 3
  • 15

1 Answers1

0

I think the temp field is empty (hence the ""), which does not parse well as a double.

Michael D
  • 678
  • 3
  • 11
  • I want the user to enter a value in the text field, so do I have to initialize a String to temp in order for it to work? – Marcella Ruiz Sep 17 '15 at 22:49