你好,游客 登录 注册 搜索
背景:
阅读新闻

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

[日期:2013-03-01] 来源:Linux社区  作者:onlyonecoder [字体:大 中 小]

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

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

在根布局里加上:

android:descendantFocusability="blocksDescendants"

然后在按钮布局里加上:

android:focusable="false"

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

下面是布局示例:

  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" 

 

  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.            /> 

更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款