2013-02-20 264 views
-1

我有一個listView。 ListView的每一行/項目包含2個視圖a TextViewImageView。我希望只有ImageView可以聚焦和點擊,textView不應該是可聚焦和可點擊的圖像視圖列表視圖項目

Eachrow.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 

android:orientation="horizontal" > 

<TextView 
    android:id="@+id/textViewEachBlockedKeyword" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Keyword" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="5dp" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<ImageView 
    android:id="@+id/imageViewBlockKeywordDelete" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="3.1" 
    android:layout_marginLeft="2dp" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 


    android:src="@drawable/delete" /> 

</LinearLayout> 

如何做到這一點? 感謝

+0

具有u嘗試設置textview中的可點擊屬性是否爲false? – Ajay 2013-02-20 09:33:32

回答

0

修改你的代碼是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 

android:orientation="horizontal" > 

<TextView 
    android:id="@+id/textViewEachBlockedKeyword" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Keyword" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="5dp" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:clickable="false" 
    android:focusable="false" /> 

<ImageView 
    android:id="@+id/imageViewBlockKeywordDelete" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="3.1" 
    android:layout_marginLeft="2dp" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 
    android:src="@drawable/delete" 
    android:clickable="true" 
    android:focusable="true" /> 

</LinearLayout> 
0
android:focusable="false" 
    android:focusableInTouchMode="false" 
    android:clickable="false" 

添加到您的TextView標籤下面

0

try代碼只是改變ImageView的到的ImageButton

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 

android:orientation="horizontal" > 

<TextView 
    android:id="@+id/textViewEachBlockedKeyword" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Keyword" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 
    android:layout_marginLeft="5dp" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<ImageButton 
    android:id="@+id/imageViewBlockKeywordDelete" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="3.1" 
    android:layout_marginLeft="2dp" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp" 
    android:src="@drawable/delete" /> 

</LinearLayout>