如何在Android中更改列表视图的第一内容的属性

问题描述 投票:0回答:1

我创建了一个可扩展的listView,在其中我要并排显示文本,这很可能是我想在那里显示2列的表格。为此,我使用了可扩展列表视图,到目前为止,它看起来像这样(下图)。my expandable list view

但是我想更改此列表第一行的颜色。像这样(下图)。what i want

至于代码,我在水平Linear Layout中使用了两个文本视图,并使用自定义适配器在视图中显示数据。这是XML。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/itemText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ellipsize="end"
        android:maxLines="1"
        android:textSize="16sp"
        android:text="item"/>

    <TextView
        android:id="@+id/itemText2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ellipsize="end"
        android:maxLines="1"
        android:textSize="16sp"
        android:text="Item2"/>

</LinearLayout>

有人可以建议我该怎么做吗?

android android-listview expandablelistview
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.