This is most likely your problem
listedPrice = Double.parseDouble(userInput.getText().toString());
The user hasn't had a chance to enter something with this code in onCreate()
so unless you have something hard-coded, you will get a NumberFormatException
. You need to place that code in an onClick()
or some other event after the user has had a chance to enter something.
You should also do some error-checking such as putting it inside of a try/catch
.
try
{
listedPrice = Double.parseDouble(userInput.getText().toString());
}
catch (NumberFormatException e)
{
// do something if invalid double
}
When posting here, you need to clearly state what is/isn't working as expected and what your problem is. Also, if your app crashes then there will be output in the logcat and you need to post that so we can easily see what/where the problem is.
Eclipse didn't say you have any problem because this is a runtime error which means that Eclipse didn't see anything wrong at compile time. Meaning your syntax is correct, as far as Eclipse knows, but your logic is not.