2013-02-20 171 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>