java - RuleBasedCollat​​or getInstance Locale.US getRules 在 Droid 中返回空字符串

标签 java android locale

在 Windows 中使用 Eclipse。

此代码适用于 JRE 1.8(Comp 级别 1.7)桌面,(字符串不为空)。

但它在 Droid 中不起作用(Comp level 1.7 - 4.4W.2 API-20)(字符串为空):

代码:

    RuleBasedCollator collTemp = (RuleBasedCollator) Collator.getInstance(Locale.US);
    String usRules = collTemp.getRules(); //==String is Empty - why?
    usRules = usRules.replace(",'-'", "");

最佳答案

Android 文档对 getRules() 方法有这样的说明

The returned string will be empty unless you constructed the instance yourself. The string forms of the collation rules are omitted to save space on the device.

您可以使用整理器,但它不会返回字符串表示形式。

http://developer.android.com/reference/java/text/RuleBasedCollator.html#getRules()

关于java - RuleBasedCollat​​or getInstance Locale.US getRules 在 Droid 中返回空字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31416957/

相关文章:

java - Android studio 使用Split方法能够从数据库中删除待办事项列表

javax.persistence.PersistenceException : Unable to locate persistence units

java - 如何更改 Android O/Oreo/api 26 应用程序语言

基于 python 的 Dockerfile 抛出 locale.Error : unsupported locale setting

java - 让 Nexus 从没有 .index 文件的存储库下载依赖项

java - Gradle war 插件: creates an intermediate directory in project root

java - ArrayList Adapter (for ListView) 只显示第一个添加的项目

android - 滚动 RecyclerView 以在顶部显示所选项目

android - 如何在 Flutter 中创建可扩展的 ListView

java - 在 Java 中更改打印流的语言环境