我正在尝试禁用对行的点击效果。我使用了绑定到 ArrayAdapter 的自定义行。我已经尝试过android:clickable="false", android:focusable="false"
ListView、TextView、按钮和图像视图,它们用于在行中显示。
这是我的“web_message_list.xml”
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/exclamation_feather_top"
>
<RelativeLayout
android:id="@+id/titleArea"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/top_head">
<ImageView
android:id="@+id/btn_Cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cancel"
android:layout_marginTop="6dp"
android:layout_marginLeft="2dp"
android:layout_alignParentLeft="true"
android:visibility="gone"
/>
<TextView
android:id="@+id/contact_title"
style="?customTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:text="Messages" />
<ImageView
android:id="@+id/edit_btn"
android:layout_width="65dp"
android:layout_height="33dp"
android:layout_marginTop="3dp"
android:layout_marginRight="2dp"
android:layout_alignParentRight="true"
android:src="@drawable/edit_button"
android:scaleType="fitEnd" />
<ImageView
android:id="@+id/btnDone"
android:layout_width="65dp"
android:layout_height="33dp"
android:layout_marginTop="3dp"
android:layout_marginRight="2dp"
android:layout_alignParentRight="true"
android:src="@drawable/done_button"
android:visibility="gone"
android:scaleType="fitEnd" />
</RelativeLayout>
<ListView
android:id="@android:id/android:list"
style="@style/blackContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/titleArea"
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" >
</ListView>
</RelativeLayout>
和“web_msg_list.xml”
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/top_head"
android:id="@+id/titleArea2"
>
<TextView
android:id="@+id/btnBck"
android:layout_width="80dp"
android:layout_height="33dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="2dp"
android:layout_alignParentLeft="true"
android:background="@drawable/messages"
android:scaleType="fitStart"
/>
<TextView
android:id="@+id/usr_name"
style="?customTitle"
android:layout_width="100dp"
android:layout_height="32dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:maxLines="1"
android:singleLine="true"
android:ellipsize="end"
/>
<TextView
android:id="@+id/btnUserInfo"
android:layout_width="80dp"
android:layout_height="33dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="3dp"
android:background="@drawable/userinfo"
android:scaleType="fitStart"
/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/alarmLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/titleArea2"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="@drawable/layout_border"
android:padding="3dp" >
<TextView
android:id="@+id/lblmessage1"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignLeft="@+id/firstDivider"
android:autoLink="web"
/>
<View
android:id="@+id/firstDivider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@+id/lblmessage1"
android:background="@drawable/container_divider" />
<TextView
android:id="@+id/lblmessage2"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignLeft="@+id/firstDivider"
android:layout_below="@id/firstDivider"
android:autoLink="web"
/>
<View
android:id="@+id/secondDivider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/lblmessage2"
android:background="@drawable/container_divider" />
<TextView
android:id="@+id/lblmessage3"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignLeft="@+id/secondDivider"
android:layout_below="@id/secondDivider"
android:textSize="5dp" />
<View
android:id="@+id/thirdDivider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/lblmessage3"
android:background="@drawable/container_divider" />
<TextView
android:id="@+id/lblmessage4"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignLeft="@+id/thirdDivider"
android:layout_below="@id/thirdDivider"
android:textSize="5dp" />
</RelativeLayout>
</RelativeLayout>
还是一样,这就是 style="@style/blackContainer" 有的
<style name="blackContainer" parent="@android:style/Widget.ListView.Menu">
<item name="android:background">@drawable/container</item>
<item name="android:divider">@drawable/container_divider</item>
<item name="android:listSelector">@drawable/container_item_selector</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:focusable">false</item>
<item name="android:paddingLeft">2dp</item>
<item name="android:paddingRight">2dp</item>
<item name="android:scrollbars">none</item>
<item name="android:fastScrollEnabled">true</item>
</style>
和
@drawable/container_item_selector 是
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/transparent" />
</selector>
谢谢