Questions about percent signs in Android resource files

Source: Internet
Author: User

When editing Strings.xml, suggest that the% compilation does not pass.

<string name= "url" >http://aa.cc.com/dd?g=%rasdf</string>

Or

<string name= "Message_content" > here is the integral%1s integral, proportion%2s  %</string>

Prompt for the following error

Multiple annotations found at the line:-error:multiple substitutions specified in non-positional format; Did you mean to addthe formatted= "false" attribute?-error:unexpected end Tag String

The reason for this error is mainly because the strings string contains a percent percent (%),

There are several ways to resolve
1. Use two percent sign to denote a percent semicolon, which is

<pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_4_7825261" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_1_4607705" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><string name= "url" >http://aa.cc.com/dd?g=%%rasdf</string>

2. means

with escape character.

<pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_5_5110046" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_1_4607705" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><string name= "url" >http://aa.cc.com/dd?g=\%rasdf</string>

3. Depending on the error message, if the string does not need to be formatted, add the attribute on the <string label: formatted= "false", i.e.

</pre><p></p><pre code_snippet_id= "440326" Snippet_file_name= "blog_20140801_6_7934728" class = "html" name= "code" style= "margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_6_7934728" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><pre code_snippet_id= "440326" snippet_file_name= "blog_20140801_1_4607705" class= "html" name= "code" style= " margin-top:0px; margin-bottom:10px; font-size:13px; line-height:24.0499992370605px; Background-color:rgb (255, 255, 255); " ><string name= "url" <span style= "font-family: ' Microsoft Yahei ', Microsoft Ya Black, Arial, ' Lucida Grande ', Tahoma, Sans-seri F font-size:13px; line-height:24.0499992370605px; " >formatted= "false" </span>>http://aa.cc.com/dd?g=%rasdf</string> 

Questions about percent signs in Android resource files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.