Android 如何在listview中使用彩色字符串?

Android 如何在listview中使用彩色字符串?,android,string,android-arrayadapter,Android,String,Android Arrayadapter,在我的strings.xml文件中有这样一个字符串:some text%1$s some text 我有一个ArrayAdapter,它使用以下类型的列表项: <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight

在我的strings.xml文件中有这样一个字符串:
some text%1$s some text

我有一个
ArrayAdapter
,它使用以下类型的列表项:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:minHeight="5dp"
    android:gravity="center_vertical"
    android:id="@+id/list_item_default_textview"
    android:textColor="@color/secondary">
</TextView>

我使用
arrayAdapter.add(getString(R.string.example,parameter))
但它不使用我在字符串中定义的颜色。它对整个字符串使用
@color/secondary
。在“普通”文本视图中,字符串内的自定义颜色起作用,因此我猜问题在于ArrayAdapter,但我不知道问题是什么。或者换句话说:有没有办法让字符串中的自定义颜色与数组适配器一起工作

我有一个
ArrayAdapter


将其更改为
ArrayAdapter
<代码>字符串没有格式
CharSequences
do.

非常感谢,这就是解决方案!但我还需要做以下工作才能让它正常工作:
,这是:
arrayAdapter.add(Html.FromHtml(getString(…))
(我以前尝试过这个,但它不起作用,因为我的
ArrayAdapter
不是
ArrayAdapter
)您可能应该将它添加到您的答案中。:)