سؤال

Is there a way to extract a Spannable[] stuff from string resource? Basically something similar to

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="planets_array">
        <item>Welcome to <b>Mercury</b></item>
    <item>Welcome to <b>Venus</b></item>
    <item>Welcome to <b>Earth</b></item>
    <item>Welcome to <b>Mars</b></item>
    </string-array>
</resources>

Then I would extract the array into

Resources res = getResources();
Spannable[] planets = res.getStringArray(R.array.planets_array);

But right now eclipse is telling me to change Spannable[] to String[].

هل كانت مفيدة؟

المحلول

use getTextArray, it returns CharSequence[] instead of String[] which preserves attached spans

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top