1

我正在使用 Simple Listview 显示联系人列表中的电子邮件地址。它工作正常。现在,当我为 Listview 显示背景时,我想更改每行显示电子邮件地址的文本颜色。

请给我您的建议或任何代码。我怎样才能改变颜色?

这是代码:

<ListView
    android:id="@+id/listSendEmailFinal"
     android:layout_below="@+id/btnAddRecepients"
    android:layout_width="fill_parent"
    android:layout_height="250dip"
    android:layout_marginLeft="5dip" 
     android:layout_marginRight="5dip"
    android:background="@drawable/listview_border"
     android:cacheColorHint="#00000000"
     >
</ListView>

listview_border.xml 在哪里:

<stroke android:width="1dp" android:color="#83F52C" />
<padding android:left="2dp"
    android:top="2dp"
    android:right="2dp"
    android:bottom="2dp" />
<corners android:radius="10dp" />
<solid android:color="#E6E6FA" />

这是listview编码:

mainListView.setAdapter(new ArrayAdapter<String>(AddReceiverDialog.this,android.R.layout.simple_list_item_multiple_choice, lv_arr));

mainListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
4

1 回答 1

7

看来您使用的是简单适配器而不是自定义适配器。

在这种情况下,您可以使用所需的文本颜色创建一个主题,并将清单文件中的主题应用到您的 ListActivity。

在 values 文件夹中创建一个 xml 文件并粘贴此代码。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="mytheme" parent="@android:style/Theme.NoTitleBar">
       <item name="android:textColor">#2A88AA</item>
    </style>
</resources>

并使用附加此主题的活动,例如

 <activity
     android:theme="@style/mytheme"
    .
    .
于 2012-04-25T06:52:09.040 回答