我需要一些帮助来为 Android 应用程序设置 ListView 的样式。我正在尝试查找如何进行此类样式设置,但我认为我正在搜索错误的项目。
我的数据由 ContentProvider 返回的对象组成,CursorLoader 用于访问数据。数据将按日期包含部分标题。一个部分中的每个项目都有一个类别,我想用类别的颜色代码为最左边的边框(边距或填充)着色。请参阅下面的布局 xml。详细信息行由 3 行数据组成,左下角有一个按钮。
请参阅此 Google 绘图了解列表的外观。
绘制我想如何设置 ListView 的样式
这种格式可以吗?
感谢您的任何帮助。
<?xml version="1.0" encoding="utf-8"?>
<!--
* This file is part of MythTV for Android
*
* MythTV for Android is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MythTV for Android is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MythTV for Android. If not, see <http://www.gnu.org/licenses/>.
*
* This software can be found at <https://github.com/MythTV-Android/mythtv-for-android/>
*
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/upcoming_header_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="@+id/upcoming_header_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/body_text_1" />
</LinearLayout>
<LinearLayout
android:id="@+id/upcoming_detail_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="@+id/upcoming_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/body_text_1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/upcoming_sub_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/body_text_1" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="@+id/upcoming_channel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:textColor="@color/body_text_1" />
<TextView
android:id="@+id/upcoming_start_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@color/body_text_1" />
<Button
android:id="@+id/upcoming_dont_record"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/btn_upcoming_dont_record"
android:textColor="@color/body_text_1"
android:textSize="@dimen/text_size_small" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>