有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

安卓如何在java中将双精度值转换为n个位置(给出答案,而不是提问)

DecimalFormat df = new DecimalFormat("0.00");//if you want over four decimal places then do->"0.0000" in brackets

TextView lattextview=findViewById(R.id.lattextview);
TextView lontextview=findViewById(R.id.longtextview);
TextView alttextview=findViewById(R.id.alttextview);
TextView accuracytextview=findViewById(R.id.accuracytextview);
TextView addresstextview=findViewById(R.id.addresstextview);

String s1 = df.format(location.getLatitude());
String s2 = df.format(location.getLongitude());
String s3 = df.format(location.getAltitude());
String s4 = df.format(location.getAccuracy());
lattextview.setText("Latitude : "+s1);
lontextview.setText("Longitude : "+s2);
alttextview.setText("Altitude : "+s3);
accuracytextview.setText("Accuracy : "+s4);

共 (0) 个答案