我ListActivity定製ArrayAdapter,並按照列表項的版面項目:點擊android的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
,clickable
到false
(我發現可能有所幫助)到我的ImageView 但不幸的是,問題依然存在。請幫助,這一直在困擾着我整天。謝謝。
編輯:好的,所以William的答案幫助我解決了這個問題,現在唯一的問題是點擊項目時不會突出顯示它,當我將背景顏色更改爲黑色時(通過在清單中爲此列表活動設置新主題)。 這是我從res/values/styles/
文件夾獲取的活動主題<style name="ContentsListTheme"> <item name="android:background">@color/black</item> </style>
的自定義樣式。
爲了清楚起見,默認的ListActivity背景顏色再次爲白色。我想要黑色。當我應用上面的樣式時,禁用單擊時列出活動項突出顯示。我怎樣才能再次啓用它默認的突出顯示顏色?
謝謝。我添加onListItemClick與小'確定'吐司消息和點擊正在工作(我得到'確定'吐司消息)。但是,列表項目不會改變顏色,並在點擊時閃爍(因爲他們應該)。什麼可能是錯的? – InProgress 2013-04-25 15:20:31
@ 1atera1us你的問題是關於點擊列表項目,如果你想要關於顏色,請添加更多的代碼,並告訴我你想要什麼顏色和哪個UI – 2013-04-25 15:31:58
我編輯了我的問題。 – InProgress 2013-04-25 16:01:35