Android string resource - must contain the character "%"

So, how to include the character "%" in the string resource?

REALLY

<string name="my_string">Total discount boundary:\nmin=%1$s nmax=%2$s</string> 

INVALID

 <string name="my_string">Total discount boundary:\nmin=%1$s % nmax=%2$s %</string> 
+4
source share
4 answers

You can use %% to get the percent sign without analysis as a string format character.

+7
source

For me, this works great. I am using the Eclipse Android plugin and I can add a line containing% signs without any problems. Which tool do you use?

0
source

Adding formatted = "false" helped me. it

 <string name="parser_error_convert" formatted="false">Parser error, line %d, \'%s\', cannot convert \'%s\'</string> 

works with my lines, and I expect this to help with your lines as well. Double %% does not help, because as a result you get %% (not%).

This problem depends on the plugin version, I am using Android Developer Studio 23.0.2.

0
source

try it

 <string="my_string" format="false">bla bla bla</string> 
-1
source

Source: https://habr.com/ru/post/1438360/


All Articles