Android(安卓)ListView嵌套Button,Button事件覆盖item事件解决办法
16lz
2022-04-05
方法就是修改item布局的xml文件:
在根布局里加上:
android:descendantFocusability="blocksDescendants"
然后在按钮布局里加上:
android:focusable="false"
item和按钮都 可以点了,就OK了
下面是布局示例:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:descendantFocusability="blocksDescendants"
<Button android:id="@+id/worklog_update" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="修改" android:focusable="false" /> <Button android:id="@+id/worklog_del" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="删除" android:focusable="false" />
更多相关文章
- Gradle 修改生成apk时的文件名
- 去掉Android(安卓)app上的Title Bar
- 设置android默认属性
- Android的Button监听
- android 打开通知栏
- Android(安卓)RadioButton 单选按钮
- android 滑动加载数据
- android Studio 低版本升级gradle3.0以上版本
- Android(安卓)将Button设置为圆角