簡體   English   中英

在簡單的ListView中更改ListView文本顏色-Android

[英]Change ListView Text Color in Simple ListView - Android

我正在使用簡單列表視圖顯示聯系人列表中的電子郵件地址。 它的工作正常。 現在,當我為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);

看來您使用的是簡單適配器而不是自定義適配器。

在這種情況下,您可以創建具有所需文本顏色的主題,並將該主題在清單文件中應用到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"
    .
    .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM