Android Listview中的simpleadapter类型没有触发item的点击事件的解决办法

来源:互联网 发布:打开pdg文件的软件 编辑:程序博客网 时间:2024/06/05 20:10
</pre><pre name="code" class="html">
</pre><pre name="code" class="html">今天遇到这个问题,检查了几遍activity之后发现并没有问题。从网上找到解决方案,是在item的XML文件的最外层加上
<pre name="code" class="html">    android:descendantFocusability="blocksDescendants"
意思是让item的点击事件覆盖其中的子控件的点击事件,适用于item中有button、checkbox等控件的点击事件的情况。
可是加上后还是没有触发,最后发现我在最外层加了
<span style="white-space:pre"></span>android:clickable="true"
去掉之后就可以了,虽然不知道原因是什么。╮(╯_╰)╭
<?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:layout_marginTop="3dp"    android:descendantFocusability="blocksDescendants"    >        <RelativeLayout        android:layout_width="fill_parent"        android:layout_height="wrap_content"        >            <TextView         android:id="@+id/tv_map_detail_info_list_name"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="测试名字"        android:layout_centerVertical="true"        android:textSize="20dp"        />        <TextView            android:id="@+id/tv_map_detail_info_list_distance"           android:layout_width="wrap_content"           android:layout_height="wrap_content"   android:text="XXX米"   android:textSize="18dp"   android:layout_marginLeft="30dp"   android:layout_toRightOf="@id/tv_map_detail_info_list_name"   android:layout_centerVertical="true"           />        <TextView         android:layout_alignParentRight="true"        android:id="@+id/tv_map_detail_info_list_navi"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="点击查看路线       "        />         </RelativeLayout>        <TextView         android:id="@+id/tv_map_detail_info_list_address"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="测试地址测试地址测试地址测试地址测试地址"    android:textSize="15dp"                />        <LinearLayout        android:layout_width="fill_parent"       android:layout_height="wrap_content"       android:orientation="horizontal"       >           <TextView            android:id="@+id/tv_map_detail_info_list_price"           android:layout_width="0dp"           android:layout_height="wrap_content"   android:layout_weight="1"   android:layout_marginLeft="20dp"   android:text="价格 X.X元/小时"           />              <TextView            android:id="@+id/tv_map_detail_info_list_lastnum"           android:layout_width="0dp"           android:layout_height="wrap_content"   android:layout_weight="1"   android:text="剩余车位 XX个"           android:layout_marginLeft="10dp"           />        </LinearLayout></LinearLayout>

0 0
原创粉丝点击