Android List 自定义 Item 点击无效

List Item 自定义 layout 如下:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent" >
 5     
 6     <CheckBox 
 7         android:id="@+id/crime_list_item_solvedCheckBox"
 8         android:layout_width="wrap_content"
 9         android:layout_height="wrap_content"
10         android:gravity="center"
11         android:layout_alignParentRight="true"
12         android:enabled="false"
14         android:padding="4dp"/>
15     
16     <TextView 
17         android:id="@+id/crime_list_item_titleTextView"
18         android:layout_width="match_parent"
19         android:layout_height="wrap_content"
20         android:layout_toLeftOf="@id/crime_list_item_solvedCheckBox"
21         android:textStyle="bold"
22         android:paddingLeft="4dp"
23         android:paddingRight="4dp"
24         android:text="Crime title"/>
25     
26     <TextView 
27         android:id="@+id/crime_list_itme_dateTextView"
28         android:layout_width="match_parent"
29         android:layout_height="wrap_content"
30         android:layout_below="@id/crime_list_item_titleTextView"
31         android:layout_toLeftOf="@id/crime_list_item_solvedCheckBox"
32         android:paddingLeft="4dp"
33         android:paddingRight="4dp"
34         android:paddingTop="4dp"
35         android:text="Crime Date" />
36 
37 </RelativeLayout>

 

显示如下:

 

但是 这个 item 死活不能点击。

 

最终找到是 check box 不可用导致的问题, 因为是 只读的,就设置了 enable = false, 但是还要给 CheckBox 加一个属性: android:focusable="false", 否则这个 list item 都不能被点击。   晕死。

转载于:https://www.cnblogs.com/richardzhaoxb/p/3343251.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值