如何在计算结果 SetText 之前包含 £ 符号?
How to include £ symbol before the resulting SetText from a calculation?
我有一些代码计算两个数字,如下所示,结果给出了我需要的字符串,但我想在结果数字之前包含英镑符号,因为它是一个财务计算(工作小时数 x 小时费率) .如何让 £ 符号出现在结果之前? (希望结果是 1000 英镑而不是 1000 英镑)
非常感谢大家的帮助:-)
我当前的代码如下,
public void buttoncalcrates(View view) {
int d1, d2, thesum;
EditText e1 = (EditText) findViewById(R.id.editText4);
EditText e2 = (EditText) findViewById(R.id.hourlyrate);
TextView t1 = (TextView) findViewById(R.id.textView5);
d1 = Integer.parseInt(e1.getText().toString());
d2=Integer.parseInt(e2.getText().toString());
thesum= d1 * d2;
t1.setText(Integer.toString(thesum));
String.format(...)
用于此目的:
t1.setText(String.format("£%d", thesum));
可以找到有关不同格式设置选项的更多信息in the docs。
我有一些代码计算两个数字,如下所示,结果给出了我需要的字符串,但我想在结果数字之前包含英镑符号,因为它是一个财务计算(工作小时数 x 小时费率) .如何让 £ 符号出现在结果之前? (希望结果是 1000 英镑而不是 1000 英镑)
非常感谢大家的帮助:-)
我当前的代码如下,
public void buttoncalcrates(View view) {
int d1, d2, thesum;
EditText e1 = (EditText) findViewById(R.id.editText4);
EditText e2 = (EditText) findViewById(R.id.hourlyrate);
TextView t1 = (TextView) findViewById(R.id.textView5);
d1 = Integer.parseInt(e1.getText().toString());
d2=Integer.parseInt(e2.getText().toString());
thesum= d1 * d2;
t1.setText(Integer.toString(thesum));
String.format(...)
用于此目的:
t1.setText(String.format("£%d", thesum));
可以找到有关不同格式设置选项的更多信息in the docs。