Android文本颜色可以';不要改变
我有以下代码。当我在列表视图上发送数据时,我什么也看不到,因为颜色设置为白色。如何将颜色设置为黑色?它没有textColor属性。另外,如何删除每个列表项上的灰色Android文本颜色可以';不要改变,android,Android,我有以下代码。当我在列表视图上发送数据时,我什么也看不到,因为颜色设置为白色。如何将颜色设置为黑色?它没有textColor属性。另外,如何删除每个列表项上的灰色 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
<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>
您需要为listview的行创建一个布局,在这里您可以设置文本的颜色:
<?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);
ArrayAdapter=新的ArrayAdapter(活动,R.layout.row\u默认值,字符串);
setAdapter(适配器);
使用自定义适配器并更改文本背景