adding units to values

0 Ilijas Sahinovic · January 2, 2015
ok so this is my code:


textFresult = (TextView) findViewById(R.id.textFresult);                                               editText = (EditText) findViewById(R.id.editText);
num = editText.getText().toString();
editText2 = (EditText) findViewById(R.id.editText2); num2 = editText2.getText().toString();
double n = Double.parseDouble(num);
double r = Double.parseDouble(num2);
double f = n * r;
textFresult.setText(String.valueOf(f));

now i want to add 'N' after the value (Newtons).
for example if result is 10 i want it to show 10N or 10 N.
how to do it?

Post a Reply

Replies

Oldest  Newest  Rating
+1 Kuroodo Ditory · January 3, 2015
Just for reference purposes, another way of doing it, or if you want to create a string containing 10N you would do


String myString = f + "";

or

textFresult.setText(f + "");

You can leave the "" blank or you can add any text in there.
0 Ilijas Sahinovic · January 4, 2015
thanks guys
  • 1

Java / Android Development

106,913 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator