Android开发之ListView中的Button点击设置

时间:2015-07-10 00:16:46   收藏:0   阅读:257

在ListView的Item中,如果有Button控件,那么要实现Button和Item点击都有响应,可以将Item的Layout中Button的focusable属性设为false,然后设置layout的属性android:descendantFocusability="blocksDescendants"。

代码如下:

 1 <?xml version="1.0" encoding="utf-8"?>  
 2 <LinearLayout  
 3   xmlns:android="http://schemas.android.com/apk/res/android"  
 4   android:layout_width="fill_parent"  
 5   android:layout_height="wrap_content"  
 6   android:descendantFocusability="blocksDescendants">  
 7   <TextView  
 8     android:layout_width="fill_parent"  
 9     android:layout_height="wrap_content"/>  
10   <Button  
11     android:layout_width="wrap_content"  
12     android:layout_height="wrap_content"  
13     android:focusable="false"/>  
14 </LinearLayout>  

 

原文:http://www.cnblogs.com/liyiran/p/4634538.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!