这就是我在做的事情 - >
//get entered texts from the edittexts,and convert to integers.
Integer value1 = Integer.parseInt(sand1.getText().toString());
//doing a calculation
Double calculatedValue1 = (9.5*value1);
//set the value to the textview, to display on screen.
result1.setText("$"+ calculatedValue1.toString());
TextView中的 result1现在看起来像这样:##.#
我需要它看起来像$##.##
答案 0 :(得分:1)
将您的代码更改为以下内容:
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while (have_posts()) : the_post(); ?>
<?php get_template_part('templates/header'); ?>
<?php get_template_part('templates/page-about'); ?>
<?php get_template_part('templates/page-services'); ?>
<?php get_template_part('templates/page-portfolio'); ?>
<?php get_template_part('templates/page-contact'); ?>
<?php get_template_part('templates/footer'); ?>
<?php endwhile; ?>
</main><!-- #main -->
</div><!-- #primary -->
答案 1 :(得分:0)
您好,您可以使用此方法(Locale.US将数字格式化为美国标准,将%.2f格式化为十进制数字):
String.format(Locale.US, "%.2f", doubleValue);