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));
精彩评论