私は持ってい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)
。行ごとに画像(フォルダアイコン)を表示したい。ただし、2 つの特定の行 (たとえば、ある種のインジケーターを使用して行を識別する方法を知っていると仮定) については、異なる画像を表示したいと考えています。不明な数のフォルダーがあり、フォルダーの名前の横に各行のフォルダー アイコンが表示されるとします。また、たとえば、Word 文書と Excel ファイルがそれぞれ 1 つずつあり、それぞれに適切な画像を表示したいとします。