獲取國家的貨幣代碼時遇到問題。我的任務是獲取用戶的位置,瞭解他現在在哪個國家並獲取該國家的貨幣代碼。以下是從獲取的位置獲取國名和國家代碼的代碼:獲取國家的貨幣代碼
Geocoder gc = new Geocoder(this);
List<Address> addresses = gc.getFromLocation(
location.getLatitude(), location.getLongitude(), 5);
textView1.setText(addresses.get(0).getCountryName());
textView2.setText(addresses.get(0).getCountryCode());
這很好。現在我應該使用java.util.Currency
類來獲得Currency
對象。我可以使用Currency.getInstance(Locale locale)
方法。但是Locale
類中沒有構造函數,只允許將國家代碼作爲參數傳遞。意味着我無法爲該國創建一個對象。這怎麼解決?提前致謝。
有一個符合ISO-639語言組的構造函數'Locale(String language,String country)'。 – 2012-02-06 10:15:11
區域設置(String language,String country)? – 2012-02-06 10:17:04