Java Android studio字符串文件(行太长)。强制启用软包装以提高编辑器性能

Java Android studio字符串文件(行太长)。强制启用软包装以提高编辑器性能,java,android,xml,string,android-studio,Java,Android,Xml,String,Android Studio,我在Android studio中有23个xml文件。并且每个xml文件都有文本视图,文本以值/字符串的形式显示读取第一个错误,其余错误是第一个错误的结果,因此可以忽略它们 如果没有精确的字符串,很难判断发生了什么,但根据错误消息,我猜如下:粘贴的长文本包含特殊字符,使AAPT放大。它抱怨“以非位置格式指定的多个替换”,这意味着您有多个%s/%d/etc。。。这在Android中是不允许的 <!-- Correct non-positional with single string sub

我在Android studio中有23个xml文件。并且每个xml文件都有文本视图,文本以值/字符串的形式显示<代码>读取第一个错误,其余错误是第一个错误的结果,因此可以忽略它们

如果没有精确的字符串,很难判断发生了什么,但根据错误消息,我猜如下:粘贴的长文本包含特殊字符,使AAPT放大。它抱怨“以非位置格式指定的多个替换”,这意味着您有多个
%s
/
%d
/etc。。。这在Android中是不允许的

<!-- Correct non-positional with single string substitution -->
<string name="formatted_string">Hello %s!</string>
<!-- Correct non-positional with single string substitution -->
<string name="formatted_number">result=%d</string>
<!-- Incorrect non-positional with multiple substitutions -->
<string name="formatted_multi">Hello %s! The result is %d.</string>
<!-- Corrected non-positional to positional with multiple substitutions -->
<string name="formatted_multi_fixed">Hello %1$s! The result is %2$d.</string>

您好%s!
结果=%d
您好%s!结果是%d。
您好%1$s!结果是%2$d。
阅读“参数索引”的两章

您可以尝试以下方法:

<string name="random_string" formatted="false" translatable="false" xml:space="preserve"
        tools:ignore="TypographyQuotes,TypographyDashes,TypographyEllipsis,TypographyFractions,TypographyOther"><![CDATA["
    Long string with <anything> weird %in %it, "most" of what you put here shou'd be ok...
"]]></string>


但AAPT仍有可能不喜欢它。如果字符串很复杂,我建议将其放入
src/main/assets
src/main/res/raw
下的文件中,并使用适当的API加载这些字符串。

感谢您的回复,我会尝试使用它。Appologize,但它给了我以下信息:aidlokentype.import或AidiTokenType.package。我不知道这是什么意思,我从来没见过。你需要学会在提问时提供相关信息;该消息可能与此问题完全无关,只是构建继续进行下一步操作,但再次失败。“它不工作”、“构建失败”或“NullPointerException”是不够的,您需要提供示例代码和输入,以便读者看到发生了什么。我建议用更多的细节更新你的问题,或者问另一个问题。对不起。我还在学习这个网站。图片:您是否尝试使用CDATA包装?(由于使用UTF-8,编码看起来还可以)。还要确保您首先修复了文件中的第一个错误,因为这可能是有效的俄语文本,但上面的内容会使它将字符串解释为代码或类似内容。
<string name="random_string" formatted="false" translatable="false" xml:space="preserve"
        tools:ignore="TypographyQuotes,TypographyDashes,TypographyEllipsis,TypographyFractions,TypographyOther"><![CDATA["
    Long string with <anything> weird %in %it, "most" of what you put here shou'd be ok...
"]]></string>