我需要一些幫助樣式化Android應用程序的ListView。我想查找如何做這種類型的樣式,但我想我正在尋找錯誤的項目。樣式化Android ListView?
我的數據由ContentProvider返回的對象組成,CursorLoader用於訪問數據。數據將有按日期標題的部分。部分中的每個項目都有一個類別,我想用該類別的顏色代碼爲最左邊的邊框(邊距或填充)着色。請參閱下面的佈局xml。詳細信息行由3行數據組成,左下角有一個按鈕。
請查看此Google圖表以瞭解列表的外觀。
Drawing of how I want to style the 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>
的形象就是你的列表項或ListView? – 2012-07-10 13:43:03
@SoumyadipDas該圖片是我想要的樣子。實際的顯示效果很好。列表標題和詳細信息按預期顯示。在不需要時關閉標題,只顯示一個新的部分。我只是不確定如何在左側添加着色。 – dmfrey 2012-07-10 13:47:00
我確實認爲這隻會添加到帶有id @ id/auctions_detail_row – dmfrey 2012-07-10 13:48:58