强制textview只显示英文数字

Hus*_*Rad 6 android locale textview

我使用下面的代码来强制我的textview用英文数字显示其文本编号:

txtScale.setText("x" + String.format(Locale.ENGLISH, String.valueOf(scaleValue)));
Run Code Online (Sandbox Code Playgroud)

但它不起作用,并继续显示具有所选区域设置的数字。如果将应用程序语言环境设置为阿拉伯语,则将其显示为阿拉伯数字,如果将其设置为英语,则将其显示为英语,但是我想强制在所有州以英语显示数字。

例如,我想在阿拉伯语下面显示文本:

???? //are one two three four
Run Code Online (Sandbox Code Playgroud)

如:

1234
Run Code Online (Sandbox Code Playgroud)

如果有帮助,我可以使用以下代码手动更改应用程序的语言:

    Locale locale = new Locale(CurrentLanguage);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config,
            context.getResources().getDisplayMetrics());
Run Code Online (Sandbox Code Playgroud)

Der*_*ung 4

不太确定你需要什么,但我猜你需要这个:

txtScale.setText(String.format(Locale.ENGLISH, "x%d", scaleValue));
Run Code Online (Sandbox Code Playgroud)

String.valueOf(scaleValue)这里有错误,您已根据默认区域设置转换了数字