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

</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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值