Shubham
Shubham

Reputation: 11

saving a float value in a string variable

I want to divide two numbers fetched from edit text and save it in a TextView but I am unable to save a float type Number into String

tv.setData(div.toString()); //not working

In this code, where tv is TextView type variable and div is float type variable.

Upvotes: 0

Views: 208

Answers (1)

Richard
Richard

Reputation: 560

Use String.valueOf(div) instead of div.toString() like so:

tv.setText(String.valueOf(div));

Upvotes: 2

Related Questions