社区
Android
帖子详情
这分全给你了!!!急啊!listview中button失效
3052world
2012-03-01 10:04:25
我用了别人自定义的一个listview,可以实现横向并排加载,但是里面的ImageButton失效了,我想让ImageButton监听有效,请问该怎么做?
谢谢啦,满意回复的分全给了,很急啊
...全文
182
7
打赏
收藏
这分全给你了!!!急啊!listview中button失效
我用了别人自定义的一个listview,可以实现横向并排加载,但是里面的ImageButton失效了,我想让ImageButton监听有效,请问该怎么做? 谢谢啦,满意回复的分全给了,很急啊
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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]
【Android】
ListView
与
Button
的共存问题解决
解决android程序开发
中
ListView
和
Button
共存的问题
ListView
和
Button
点击事件冲突处理
ListView
和
Button
点击事件冲突处理,绝对有效,希望对各位有用
Android
中
ListView
的Item点击事件
失效
的快速解决方法
在平常的开发过程
中
,我们的
ListView
可能不只是简单的显示下文本或者按钮,更多的是显示复杂的布局,这样的话,我们就得自己写布局和自定义adapter了,一般是继承于BaseAdapter,示例代码见下方。写
ListView
的点击事件时OnItemClickListener,onItemClick方法没有执行,导致
ListView
中
Item条目点击事件
失效
,而Item
中
的View点击事件可以在getView方法
中
进行处理。导致整个Item点击
失效
的原因多半是由于在【你自己定义的Item
中
存在诸如Image
Button
,
Button
,CheckBox等子控件(也可以说是
Button
或者Chec
android
ListView
抢夺焦点解决办法+显示多个不同类型item
android
ListView
Button
等控件强行获取焦点导致 item监听无效的解决办法 ,利用
ListView
显示多个不同类型的item
Android
中
ListView
setOnItemClickListener点击无效原因分析
前言 最近在做项目的过程
中
,在使用
listview
的时候遇到了设置item监听事件的时候在没有回调onItemClick 方法的问题。我的情况是在item
中
有一个
Button
按钮。所以不会回调。上百度找到了解决办法有两种,如下: 1、在checkbox、
button
对应的view处加android:focusable=”false” 代码如下: android:clickable=”false” android:focusableInTouchMode=”false” 2、在item最外层添加属性 android:descendantFocusability=”blocksDesce
Android
80,472
社区成员
91,384
社区内容
发帖
与我相关
我的任务
Android
移动平台 Android
复制链接
扫一扫
分享
社区描述
移动平台 Android
android
android-studio
androidx
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章