ListView中的button问题

WindKun 2012-09-18 02:38:06
下面是主XML,是一个自定义的ListView:
<com.dingruan.view.MyListView
android:id="@+id/station_in_List"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10.0dip"
android:layout_marginRight="10.0dip"
android:cacheColorHint="@null"
android:divider="#ffffff"
android:listSelector="#00000000" >
</com.dingruan.view.MyListView>

下面是ListView的ItemXML的部分代码:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:descendantFocusability="blocksDescendants" >
<Button
android:id="@+id/tanker_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/tanker_button_pause"
android:gravity="bottom"
android:visibility="gone" />
<Button
android:id="@+id/tanker_using"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="@drawable/tanker_button_using"
android:gravity="bottom"
android:visibility="gone" />
</RelativeLayout>
上面的是部分主要代码,当点击ListView的Item时,button也跟着响应了点击的事件,求各位大神帮忙改改,怎样才能让ListView的Item与button的点击事件分开?
...全文
138 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
行猿 2013-05-03
  • 打赏
  • 举报
回复
不要监听listview的setOnItemClickListener事件,因为button在item上,监听上述事件时难免会触发button的按下效果,可以试着监听listview Item上其他控件的OnClickListener事件完成你所要的需求,这样你的问题就解决了。
catokat 2012-09-19
  • 打赏
  • 举报
回复
http://mycoding.iteye.com/blog/1071844
今夜不谈风月 2012-09-19
  • 打赏
  • 举报
回复
首先把你要在listItem中显示的东西提出来成一个对象,然后自己制定个适配器 adapter ,里面有一个list存放每一个item的对象。然后在这里就可以写按钮的点击事件了。
WindKun 2012-09-18
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
这个需要自定义适配器,很简单的。
[/Quote]
怎么自定义啊!不懂!
zhubo330513 2012-09-18
  • 打赏
  • 举报
回复
这个需要自定义适配器,很简单的。
WindKun 2012-09-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
自定义adapter 就OK了
[/Quote]
怎么自定义!
___________超 2012-09-18
  • 打赏
  • 举报
回复
自定义adapter 就OK了

80,263

社区成员

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

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