Search code examples
androidembedded-resource

TextView throws designer error displaying string resource


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" />

Solution

  • 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.