使用语言环境设置来检测使用英制单位 [英] Using locale settings to detect wheter to use imperial units

查看:112
本文介绍了使用语言环境设置来检测使用英制单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个想要以厘米(cm)或以英寸()来显示长度的应用程序.是否有一种方法可以从语言环境中选择正确的单位?放置一个选项,以便用户可以覆盖区域设置.

I'm working on an app that wants to display lengths either in centimeters (cm) or in inches("). Is there a way to select the right unit from the locale? In any event I'm also going to put in an option so that the user can to override the locale setting.

美国,利比里亚和缅甸应使用英制单位和世界其他正常单位.一种方法是在我自己的类中放入此逻辑,但是我更喜欢使用任何内置的逻辑(如果有).有指针吗?

USA, Liberia, and Burma should use imperial units and the rest of the world normal units. One way is to put in this logic in my own classes, but I would prefer using any built in logic if available. Any pointers?

推荐答案

LocaleData.getMeasurementSystem is available from API level 28 and beyond. It returns the information you are looking for.

这篇关于使用语言环境设置来检测使用英制单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆