Monday, May 30, 2011

Android strings.xml

Here's a strange one - I was working on an Android application, using the strings.xml file for the apps string resources. It so happened that I needed to have two strings in both underlined and non-underlined forms. So I added:
<string name="average_underlined"><u>average</u></string>
<string name="recent_underlined"><u>recent*</u></string>
<string name="average">average</string>
<string name="recent">recent</string>


to the strings.xml file. However, when I ran the app the underlined versions appeared where I expected the regular version to appear. After checking and rechecking I was happy the code was correct. Bizarrely, the fix was to have the non-underlined versions declared first:
<string name="average">average</string>
<string name="recent">recent*</string>
<string name="average_underlined"><u>average</u></string>
<string name="recent_underlined"><u>recent*</u></string>


If anyone can explain this to me please do get in touch!

No comments:

Post a Comment