如何在低api中使用getCurrencyInstance和format?

Moh*_*oun 2 java android android-debug android-studio android-developer-api

我在以下代码中收到错误:

private void displayPrice (int number) {

    TextView price = (TextView)findViewById(R.id.txt_price);
    price.setText(NumberFormat.getCurrencyInstance().format(number));
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误如下:

Call requires API level 24 (current min is 14): android.icu.text.NumberFormat#getCurrencyInstance
Run Code Online (Sandbox Code Playgroud)

Android API 24可以使用此功能.我怎样才能在低API中使用它API 15

ian*_*ake 11

更改导入以使用java.text.NumberFormat(可从API 1获得)而不是android.icu.text.NumberFormat(可从API 24获得).

ICU4J框架提供了更好的国际化支持,但它不是必需的.