• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Edittext to String and multiply with Spinner

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
Posts: 79401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic