[英]Android Text Color can't be change
我有以下代碼。 當我在列表視圖上發送數據時,我看不到任何東西,因為顏色設置為白色。 如何將顏色設置為黑色? 上面沒有textColor屬性。 另外,如何刪除每個列表項上的灰色。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="1"
android:background="#f8f8f8"
android:orientation="vertical" >
<ListView
android:id="@+id/output_area"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="1dp"
android:background="#ffffff"
android:drawSelectorOnTop="false" >
</ListView>
</LinearLayout>
</LinearLayout>
您需要為列表視圖的行創建一個布局,在這里您可以設置文本的顏色:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/default_listview_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:padding="5dp"
/>
然后像這樣使用它:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, R.layout.row_default, strings);
listView.setAdapter(adapter);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.