Android ListView嵌套Button,Button事件覆盖item事件解决办法

来源:互联网 发布:foxtable同类软件 编辑:程序博客网 时间:2024/05/22 07:05

方法就是修改item布局的xml文件:

根布局里加上:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. android:descendantFocusability="blocksDescendants"  

然后在按钮布局里加上:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. android:focusable="false"  

item和按钮都 可以点了,就OK了



下面是布局示例:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical"   
  6.     android:descendantFocusability="blocksDescendants"  



[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <Button  
  2.            android:id="@+id/worklog_update"  
  3.            android:layout_width="wrap_content"  
  4.            android:layout_height="wrap_content"  
  5.            android:text="修改"   
  6.            android:focusable="false"  
  7.            />  
  8.   
  9.        <Button  
  10.            android:id="@+id/worklog_del"  
  11.            android:layout_width="wrap_content"  
  12.            android:layout_height="wrap_content"  
  13.            android:text="删除"   
  14.            android:focusable="false"  
  15.            />  
0 0
原创粉丝点击