Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

displays float into Text View

Tags:

android

I want to display a float into Text View

like image 657
mobileDeveloper Avatar asked Mar 23 '11 08:03

mobileDeveloper


People also ask

What is the use of text view?

TextView is the user interface which displays the text message on the screen to the user. It is based on the layout size, style, and color, etc. TextView is used to set and display the text according to our specifications.

How do you create a text view?

Set the Text of Android TextView Following is another way to set the text of textview control programmatically in activity file using setText() method. TextView tv = (TextView)findViewById(R. id. textView1);

What is the difference between text view and plain text in Android Studio?

Textview : should be used for uneditable text which user wants to read but not to manipulate. e.g. News, Articles, Blogs. Plain text/ Edittext : should be used for taking user input in alphanumeric form. e.g. UserId, Comments.


2 Answers

Try this :

 float myfloatvariable=(float) 2.33333;
 String mytext=Float.toString(myfloatvariable);
 TextView.setText(mytext);
like image 132
Kartik Domadiya Avatar answered Sep 29 '22 17:09

Kartik Domadiya


Try this

  • myTextView.setText(Float.toString(floatVar));

  • myTextView.setText(String.valueOf(floatVar));

  • myTextView.setText(floatVar+"");

like image 34
Ganapathy C Avatar answered Sep 29 '22 19:09

Ganapathy C