Android layout Android:在没有自定义适配器的情况下更改ListView中文本的颜色

Android layout Android:在没有自定义适配器的情况下更改ListView中文本的颜色,android-layout,Android Layout,是否可以在ListView中更改textColor而不为其定义自定义适配器?正如在TextView中一样,我们可以应用style=“@style/mystyle”,在其中我们可以定义textcolor <ListView android:id="@+id/listview" style="@style/WhiteText" /> 在“值”中,样式定义为: <resources> <style name= "Wh

是否可以在ListView中更改textColor而不为其定义自定义适配器?正如在TextView中一样,我们可以应用style=“@style/mystyle”,在其中我们可以定义textcolor

    <ListView
    android:id="@+id/listview" 
    style="@style/WhiteText"
    />

在“值”中,样式定义为:

    <resources>
    <style name= "WhiteText">
    <item name ="android:textColor">#FFFFFF </item>
    <item name="android:background">#000000 </item>
    </resources>

#FFFFFF
#000000 

我试过了,但它没有给我想要的输出。因此,我想问,这是否是一种有效的方法?

可以定义ListView的样式并设置该样式的文本颜色

请参见下面的答案:

希望它能帮助你。
如果有任何疑问,请告诉我。

在SO的两个答案中,都使用自定义ListView。我只是想更改ListView的textColor,所以我想知道有没有什么方法可以不使用自定义listadapter轻松完成此操作?@SternBravo:您只能使用列表视图的样式来完成此操作