【发布时间】:2012-02-06 10:04:20
【问题描述】:
我在获取某个国家/地区的货币代码时遇到问题。我的任务是获取用户的位置,找出他现在所在的国家,并得到这个国家的货币代码。下面是从获取的位置获取国家名称和国家代码的代码:
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 类中没有构造函数只允许将国家代码作为参数传递。意味着我无法为该国家/地区创建 Locale 对象。如何解决?提前致谢。
【问题讨论】:
-
有一个构造函数
Locale(String language, String country)符合ISO-639语言组。 -
区域设置(字符串语言,字符串国家)?
标签: java android location locale currency