-2
    Double  x=Double.parseDouble(textview.getText().toString());
    Double  y=Double.parseDouble(edittext.getText().toString());
    Double  z=x*y;

    finalcost=z+costofevents;

or is their any new way to find two value and add to finalcost object

1 Answers1

1

If Double.parseDouble(...) is what causing problem then try converting String to Double like

Double.valueOf(textview.getText().toString());

Edit:

Also make sure you have declared your TextView and EditText properly.

Shahzeb
  • 3,696
  • 4
  • 28
  • 47
  • no difference. Double.valueOf calls parseDouble internally and throws exactly same exception – kiruwka Oct 28 '14 at 19:47
  • what is the exception? – Shahzeb Oct 28 '14 at 19:47
  • NullPointerException if the string is null. NumberFormatException if the string does not contain a parsable double. – kiruwka Oct 28 '14 at 19:48
  • @Funkystein Wrong: the answer you posted is talking about `Double.valueOf(double)` while I talk here about `Double.valueOf(String)` which calls `Double.parseDouble(String)` internally. Please check the sources if you like – kiruwka Oct 28 '14 at 19:53
  • btw @Funkystein answer is about Double.valueOf(String) (Correction) – Shahzeb Oct 28 '14 at 19:55
  • @Shahzeb In facts, the link i posted has this title: `What is difference between Double.parseDouble(string) and Double.valueOf(string)?` If you and kiruwka would read, before commenting... – Phantômaxx Oct 28 '14 at 19:58
  • @Funkystein well, if you clicked the links in the answer(or read the accepted answer) you would see that it does talk about `Double.valueOf(double)`. We could also save time if you would just look at the sources. I repeat : `Double.valueOf(String)` calls `Double.parseDouble(String)`. – kiruwka Oct 28 '14 at 20:02