我想在TextView中显示一个浮点数
我想在TextView中显示一个浮点数
试试这个:
float myfloatvariable=(float) 2.33333;
String mytext=Float.toString(myfloatvariable);
TextView.setText(mytext);
试试这个
myTextView.setText(Float.toString(floatVar));
myTextView.setText(String.valueOf(floatVar));
myTextView.setText(floatVar+"");
///// 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));
如果我理解你的意思正确,你想要类似于这样的东西
myText.setText = myFloat.toString();
这是我个人使用过的东西。
aTextView.setText(Float.toString(yourFloat));