这分全给你了!!!急啊!listview中button失效

3052world 2012-03-01 10:04:25
我用了别人自定义的一个listview,可以实现横向并排加载,但是里面的ImageButton失效了,我想让ImageButton监听有效,请问该怎么做?
谢谢啦,满意回复的分全给了,很急啊
...全文
182 7 打赏 收藏 转发到动态 举报
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]

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧