0

In working with a new Android project in Eclipse, with the default layout, I discovered a behavior that I'm sure is documented... somewhere... but I cannot identify where.

When the strings.xml "hello" resource contains a string that looks like this:

    <string name="hello" 
    formatted="false">@BrandingName: Branding phrase ending with @
    </string>

The Eclipse designer throws ArrayIndexOutOfBounds resolving a resource value. I presume this is because it doesn't know how to escape some part of "@BrandingName:" correctly? What would be the way to correctly display this using a TextView?

For reference the TextView node looks like this:

    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

2 Answers 2

1

Try to use entity instead of '@' - &#64

And also, if you want to have a formatting for your string, you could use CDATA like this:

<string name="hello"><![CDATA[ @BrandingName: Branding phrase ending with @ ]]></string>
Sign up to request clarification or add additional context in comments.

2 Comments

<string name="hello" formatted="false">&#64;BrandingName: Branding phrase ending with &#64;</string> yields the same exception. The formulation with CDATA works as long as there is a space before the @. Apparently, starting a string resource with @ attempts to resolve the resource as an indirection...
+1 for the example that got me close enough to discover the leading-@ bug (at least it looks like a bug)
0

Starting a string resource with "@" will cause errors in the designer. A leading space will prevent that error. The leading space does not appear to be rendered in the TextView.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.