2017-08-08 22 views
-1

这是我的代码无法解析符号数字格式的Android

private void displayPrice(int number) { 
     TextView priceTextView = (TextView) findViewById(R.id.price_text_view); 
     priceTextView.setText(NumberFormat.getCurrencyInstance().format(number)); 
    }} 

我越来越不能解析符号“数字格式”。

+0

试试这个:https://stackoverflow.com/a/40390618/1343788 –

+1

你导入'NumberFormat'类?更具体地说,这个导入是出现在Java文件的顶部,还是Android Studio通过将它置于红色文本中来标记'NumberFormat'? –

回答

1

您应该的java.text

导入NumberFormat类

你的import语句会喜欢下面。

import java.text.NumberFormat 
1

导入此其工作

import java.text.NumberFormat;