0

In layout xml file, I set properties using @string like this:

<com.hardpass.MyCustomComponent
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    mynamespace:title="@string/xxootitle" />

How to deal with @string/xxootitle in custom component com.hardpass.MyCustomComponent? Or how to parse @string/xxootitle to the real value which is defined in strings.xml.

String title = attrs.getAttributeValue(mynamespace, "title"); 
//the title got here is "@string/xxootitle",
//but how to parse `@string/xxootitle` to the real value which is defined in strings.xml.
hardPass
  • 19,033
  • 19
  • 40
  • 42

1 Answers1

2

use getAttributeResourceValue and getString,

getString(attrs.getAttributeResourceValue(mynamespace, "title", R.string.xxootitle));
Kendroid
  • 116
  • 4