社区
Android
帖子详情
这分全给你了!!!急啊!listview中button失效
3052world
2012-03-01 10:04:25
我用了别人自定义的一个listview,可以实现横向并排加载,但是里面的ImageButton失效了,我想让ImageButton监听有效,请问该怎么做?
谢谢啦,满意回复的分全给了,很急啊
...全文
237
7
打赏
收藏
这分全给你了!!!急啊!listview中button失效
我用了别人自定义的一个listview,可以实现横向并排加载,但是里面的ImageButton失效了,我想让ImageButton监听有效,请问该怎么做? 谢谢啦,满意回复的分全给了,很急啊
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
追风筝的孩子
2012-03-01
打赏
举报
回复
。。。好像会混乱的,在listview上加上checkbox。条目一多就会顺序混乱,需要手工维护
licaiyuren
2012-03-01
打赏
举报
回复
button的焦点失效是吧?可能被别的元素,如listView的Item抢夺了。
android:focusable="false"
danielinbiti
2012-03-01
打赏
举报
回复
在getview内通过findViewById找到按钮,然后定义onclick,和布局没关系
kity
2012-03-01
打赏
举报
回复
然后看看这个http://blog.csdn.net/fulianwu/article/details/6538406
kity
2012-03-01
打赏
举报
回复
设置android:focusable="false"
3052world
2012-03-01
打赏
举报
回复
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="@+id/scan_deviceimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/gas" />
<ImageView
android:id="@+id/scan_seperate_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scan_deviceimage"
android:layout_marginLeft="20dip"
android:background="@drawable/seperateline" />
<ImageButton
android:id="@+id/scan_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scan_seperate_line"
android:layout_marginLeft="5dip"
android:background="@drawable/switch_on"
/>
<TextView
android:id="@+id/scan_nametext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scan_switch"
android:layout_marginLeft="10dip"
android:text="1号"
android:textColor="#FFF" />
<TextView
android:id="@+id/scan_situationtext"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_below="@id/scan_nametext"
android:text="WARNING"
android:textColor="#FFF" />
</RelativeLayout>
这是我list_row.xml文件
xiaojian623
2012-03-01
打赏
举报
回复
这个应该可以[Quote=引用 4 楼 danielinbiti 的回复:]
在getview内通过findViewById找到按钮,然后定义onclick,和布局没关系
[/Quote]
当
ListView
中
有
Button
,如何使setOnItemClickListener
失效
在Android开发
中
,遇到
ListView
中
包含
Button
时,setOnItemClickListener可能
失效
。解决方法包括修改item根布局属性、调整
Button
焦点属性或在Adapter
中
直接监听。原因是
Button
的focusable属性导致其父View无法捕获点击事件。通过源码分析可以理解这一现象。
Android
ListView
item有
button
时,item点击事件
失效
博客主要讲述Android
中
ListView
条目
中
有
button
时,item点击事件
失效
的问题。通过重新布局,将
button
点击事件写在自定义适配器,
ListView
条目点击事件写在Activity,设置
button
属性及Item布局根布局属性,解决了点击事件问题,使两者监听均可正常使用。
android
ListView
上有checkBox、
button
时导致onListItemClick方法
失效
的解决办法
本文解决了一个常见问题:在Android开发
中
,当
ListView
项内含有CheckBox或
Button
时,
ListView
的onListItemClick监听方法会
失效
。文章提供了简单有效的解决方案,即通过在
ListView
项布局文件
中
设置android:descendantFocusability=blocksDescendants来阻止子控件获取焦点。
listview
的item里面有
Button
,并给其设置了点击事件,而且有效可点击,但是
listview
的item点击事件却
失效
了
本文介绍了解决
ListView
中
Button
与Item点击事件冲突的三种方法。包括调整descendantFocusability属性值,将
Button
改为自定义View并设置点击监听,及在内部处理所有点击事件。
Button
点击事件和
LIstview
子控件点击事件
失效
本文介绍了在Android开发
中
遇到的
button
点击事件
失效
的原因及解决办法,并详细解释了
ListView
中
item点击事件
失效
的情况及其解决方案。
Android
80,490
社区成员
91,374
社区内容
发帖
与我相关
我的任务
Android
移动平台 Android
复制链接
扫一扫
分享
社区描述
移动平台 Android
android
android-studio
androidx
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章