Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用需要api级别为24(当前最小值为21)的新android.icu.text.DecimalFormat_Android_Parse Platform - Fatal编程技术网

调用需要api级别为24(当前最小值为21)的新android.icu.text.DecimalFormat

调用需要api级别为24(当前最小值为21)的新android.icu.text.DecimalFormat,android,parse-platform,Android,Parse Platform,抱歉,我是新手,在旧的API或API中如何调用此功能? 获取此警告调用需要api级别为24(当前最小值为21)的新android.icu.text.DecimalFormat public static String roundThousandsIntoK(Number number) { char[] suffix = {' ', 'k', 'M', 'B', 'T', 'P', 'E'}; long numValue = number.longValue(); int

抱歉,我是新手,在旧的API或API中如何调用此功能? 获取此警告调用需要api级别为24(当前最小值为21)的新android.icu.text.DecimalFormat

public static String roundThousandsIntoK(Number number) {
    char[] suffix = {' ', 'k', 'M', 'B', 'T', 'P', 'E'};
    long numValue = number.longValue();
    int value = (int) Math.floor(Math.log10(numValue));
    int base = value / 3;
    if (value >= 3 && base < suffix.length) {
        return new DecimalFormat("#0.0").format(numValue / Math.pow(10, base * 3)) + suffix[base];
    } else {
        return new DecimalFormat("#,##0").format(numValue);
    }
}
公共静态字符串round000和sintok(数字){
char[]后缀={'','k','M','B','T','P','E'};
long numValue=number.longValue();
int值=(int)Math.floor(Math.log10(numValue));
int base=值/3;
如果(值>=3&&base
您应该使用java的十进制格式

java.text.DecimalFormat

请参阅更多信息

要解决require API级别错误,您可以执行以下步骤:- 1) 归档 2) 然后选择“项目结构” 3) 然后进入模块部分,点击“默认配置” 4) 向下滚动并单击min SDK版本并选择
5) 按ok

您可能需要
java.text.DecimalFormat
而不是
android.icu.text.DecimalFormat
。检查文件顶部的
import
语句。哇,太快了,非常感谢您使用java十进制格式此错误甚至不存在此情况对使用icu版本没有好处。类似的api警告通常需要使用build.version测试的替代代码。降低SDK版本应该考虑目标受众,而不仅仅是为了处理编码问题。