作为android的新手我有一些代码组合如下,目的是根据自定义语言环境显示不同的特定数字12345.66。然而,它只是坠毁我的测试应用程序,我无法弄清楚为什么...在这里感谢一些帮助。提前感谢!android - 基于语言环境的数字格式化
//get current locale and display number
Configuration sysConfig = getResources().getConfiguration();
Locale curLocale = sysConfig.locale;
String aNumber = "12345.66";
NumberFormat nf = NumberFormat.getInstance(curLocale);
aNumber = nf.format(aNumber);
numberText.setText(R.string.numberText + aNumber);
Layout.xml:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/nbumberText"
/>
你会得到什么例外? – SLaks
错误消息显示:抱歉,该应用程序意外停止。请再试一次。然后我必须强制关闭应用程序。 – Liliw