首先我们的Listview如果是自定义的一般会有一个布局文件xxx.xml
在这个xml中第一个元素一般是LinearLayout或RelativeLayout
中加上
android:descendantFocusability="blocksDescendants"
然后其中的ImageButton,或Button我们为其设置
android:clickable="true"
android:focusable="false"
两个属性,就可以实现button和Listview同时点击的效果。
在这个xml中第一个元素一般是LinearLayout或RelativeLayout
中加上
android:descendantFocusability="blocksDescendants"
然后其中的ImageButton,或Button我们为其设置
android:clickable="true"
android:focusable="false"
两个属性,就可以实现button和Listview同时点击的效果。
本文介绍如何通过修改自定义ListView的布局文件实现按钮与ListView同时响应点击事件的方法。具体操作包括设置LinearLayout或RelativeLayout的android:descendantFocusability属性为blocksDescendants,并为ImageButton或Button设置android:clickable=true和android:focusable=false。
172

被折叠的 条评论
为什么被折叠?



