开发者

displays float into Text View

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜