カスタム ArrayAdapter を使用した ListActivity と、リスト項目の次のレイアウトがあります。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingTop="5dip"
android:paddingBottom="5dip" >
<ImageView
android:id="@+id/image"
android:layout_width="48dip"
android:layout_height="48dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="24.5sp" />
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="12sp"/>
</LinearLayout>
私の問題は、リスト項目のいずれかをクリックできないことです。私がこれまでに試したことはfocusable
、(私が見つけた) to を ImageView に設定することですが、残念ながら問題が残っていますclickable
。false
助けてください、これは一日中私を悩ませています。ありがとうございました。
編集: OK、William の回答がこれを助けてくれました。唯一の問題は、背景色を黒に変更したときに (このリスト アクティビティのマニフェストに新しいテーマを設定することにより)、項目をクリックしても強調表示されないことです。これは、フォルダー<style name="ContentsListTheme">
<item name="android:background">@color/black</item>
</style>
からのアクティビティ テーマのカスタム スタイルです。res/values/styles/
明確にするために、もう一度言いますが、デフォルトの ListActivity の背景色は白です。黒くしたい。上記のスタイルを適用すると、クリック時のリスト アクティビティ アイテムの強調表示が無効になります。デフォルトの強調表示色に戻すにはどうすればよいですか?