作爲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