How to display formatted amounts in TextView?
<p>I have a currency symbol in <code>String</code> and an amount in <code>double</code>. Till now I am showing amounts like this:</p>

<pre><code>amount.setText(currency + " " + amount);
</code></pre>

<p>And at some places I have 2 <code>TextView</code>s to display amount with padding in between:</p>

<pre><code>currency.setText(currency);
amount.setText(amount);
</code></pre>

<p>Which is fine. But, I am moving this code to the layout files with android data-binding and is there an easy way to format and show amounts in android?</p>

<p>Like <code>symbol[space]amount</code>  where amount should be formatted with 2 decimal points if present, else whole number. For example, 100 will be displayed as 100, and not 100.00, but 123.2 will be displayed as 123.20 along with the currency symbol at first ($ 123.20, $ 100).</p>

<p>I know there are several ways(resource string format, NumberFormat) I can do that(I have not yet used any of them, just heard of them), but what will be the easiest and cleanest way to do this? </p>

<p>I am trying to find and convert all the 2 text views to single one and finding unified way to format and display amounts.</p>

<p>Thank you.</p>