开发者

displays float into Text View

开发者 https://www.devze.com 2023-02-18 23:22 出处:网络
I want to dis开发者_开发技巧play a float into Text ViewTry this : float myfloatvariable=(float) 2.33333;

I want to dis开发者_开发技巧play a float into Text View


Try this :

 float myfloatvariable=(float) 2.33333;
 String mytext=Float.toString(myfloatvariable);
 TextView.setText(mytext);


Try this

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

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

  • myTextView.setText(floatVar+"");


If I understood you correctly you want something like

myText.setText = myFloat.toString();


///// for float value ////
Float flt_value = 1.134f;
txt_total.setText(String.format("%.02f",flt_value));

///// for double value ////
double dbl_value = 1.134;
txt_total.setText(String.format("%.2f",dbl_value));


Something that I have used in my own experience.

aTextView.setText(Float.toString(yourFloat));
0

精彩评论

暂无评论...
验证码 换一张
取 消