【问题标题】:the currency symbol I have chosen does not appear on the screen我选择的货币符号没有出现在屏幕上
【发布时间】:2018-05-10 22:13:57
【问题描述】:

XML 代码在这里:

<TextView
    android:id="@+id/price_text_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="€0"
    android:textAllCaps="true"
    android:layout_marginTop="16dp"
    android:textSize="16sp"
    android:textColor="@android:color/black"/>

java代码:

//This method displays the given price on the screen.
private void displayPrice(int number) {
    TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
    priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
}

当我单击按钮时,出现sterlin 符号而不是euro 符号。我认为是链接“数字格式”,但我不知道。

你能帮帮我吗?我附上了我手机的屏幕截图。

我尝试学习安卓应用开发, 谢谢

当我点击按钮时,我看到了这个屏幕:

【问题讨论】:

    标签: java android number-formatting


    【解决方案1】:

    试试这样的:

    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(new Locale("da", "DK"));
    
    numberFormat.setCurrency(Currency.getInstance("EUR")); 
    String currencyString = numberFormat.format(number);
    
    priceTextView.setText (currencyString);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      • 2018-03-29
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 2011-11-26
      相关资源
      最近更新 更多