ListView 中含有Button ,让它Item能接收事件,并且button能够接收事件

来源:互联网 发布:阿里 西安 云计算 编辑:程序博客网 时间:2024/06/05 16:26

每个Item中加入

android:descendantFocusability="blocksDescendants"  
用来屏蔽focus 事件。使Item可以进行Foucs



<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="85dp"    android:gravity="center_vertical"    android:paddingLeft="10dp"    android:paddingRight="10dp"    android:descendantFocusability="blocksDescendants"      android:background="@drawable/windowlist_item_selector" ><ImageView android:id="@+id/loading"android:layout_width="25dp"android:layout_height="25dp"android:src="@drawable/favico"android:focusable="false"android:layout_alignParentLeft="true"/><TextViewandroid:id="@+id/text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="14dip"android:layout_marginLeft="10dp"android:focusable="false"android:layout_toRightOf ="@id/loading"/>    <Buttonandroid:id="@+id/close"android:background ="@drawable/windowlist_close_button_selector"android:layout_width="25dp"android:layout_height="25dp"android:layout_alignParentRight="true"android:focusable="false"android:clickable="true"/></RelativeLayout>


原创粉丝点击