我有一个ListView
:
...
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?android:attr/colorBackground"
android:cacheColorHint="?android:attr/colorBackground"
android:choiceMode="singleChoice"
android:drawSelectorOnTop="false"
android:fadingEdge="none"
android:fastScrollEnabled="true"
android:scrollingCache="true" />
...
以及列表项的布局:
...
<ImageView
android:id="@+id/folder_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:paddingTop="3dip"
android:src="@drawable/icon_folder" />
<TextView
android:id="@+id/fol_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/folder_image"
android:textSize="22dip" />
...
是ListView
使用setListAdapter(SimpleCursorAdapter)
. 对于每一行,我想显示一个图像(文件夹图标)。但是,对于两个特定的行(假设我知道如何使用例如某种指示器来识别行),我想显示不同的图像。假设我有一个不确定数量的文件夹,并且文件夹图标将显示在文件夹名称旁边的每一行。假设我有,例如,一个 Word 文档和一个 Excel 文件,每个文件都各有一个,我想为每个文件显示适当的图像。