android - How to display EditText in a TextView after changing it to BigDecimal? -


i want precise number edittext change in bigdecimal , show in textview. here's part of code:

bigdecimal rate_string = new bigdecimal(0); edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = (bigdecimal) rate.gettext(); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); 

but doesn't work! should do? thanks

bigdecimal rate_string = new bigdecimal(0); edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = (bigdecimal) rate.gettext(); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); 

to

bigdecimal rate_string; // p.s here useless creation edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = new bigdecimal( rate.gettext().tostring() ); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); 

you cannot convert string bigdeciaml using cast bigdecimal have constructor takes value string.

p.s make sure pass correct number constructor or throw numberformatexception!


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -