Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Edittext to String and multiply with Spinner

 
Adde Berg
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I´m currently working on a currency converter project for school. I have an array with currencies (USD,EUR etc) and one with values (6.54, 9.56 etc).

I have two spinners and one EditText and you choose From unit in one spinner and To unit in the other. Then it should consider the amount in editText and show the "live" result in textView. If you change spinners or editText the value in textview should update directly.

Let's say that the value inserted in editText is 10.0, and we want to convert it from USD to EUR, the calculation will look like this: 10.0*6.54/9.56=

But I can't figure out how to add the editText in to the calculation. And I also get an error message saying I have an empty String



Here is the error log:
 
Campbell Ritchie
Sheriff
Posts: 51368
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Doesn't the error message make it plain? NumberFormatException(←link) and “empty string”. It means you cannot get a number out of your text box until you put some content in it.
I suggest you use a Scanner. Did you know that you can create a Scanner from a text box? Well, actually, you can't, but you can do the next best thing: create a Scanner dealing with the contents of a text box:-Beware: if you enter "123.456 Adde Berg" in the text box, it will happily give you a return value of a BigDecimal containing 123.456.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic