setOnItemClickListener+自定义item点击无响应

来源:互联网 发布:淘宝网买剃须刀片 编辑:程序博客网 时间:2024/05/16 11:24
//
//根布局设置 android:descendantFocusability="blocksDescendants"
//里面的控件设置为了方便全部设置上必定完美解决点击无响应
 //android:clickable="false" //android:focusableInTouchMode="false" // android:focusable="false"
//愿意你狠简单就是这些控件抢占当前页面焦点 从而点击我们自定义的item无响应 
//下面是例子代码
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:descendantFocusability="blocksDescendants"    >    <android.support.v7.widget.CardView        android:clickable="false"        android:focusableInTouchMode="false"        android:focusable="false"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginBottom="20px">        <LinearLayout            android:clickable="false"            android:focusableInTouchMode="false"            android:focusable="false"            android:foreground="@drawable/iv_ripple_green"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:background="@drawable/round_white_layout_bg"            android:gravity="center_horizontal"            android:orientation="vertical"            android:paddingBottom="30px"            android:paddingLeft="40px"            android:paddingRight="40px"            android:paddingTop="30px">            <com.flippedteacher.classroom.view.CircleImageView                android:clickable="false"                android:focusableInTouchMode="false"                android:focusable="false"                android:id="@+id/classmate_icon"                android:layout_width="110px"                android:layout_height="110px"                android:layout_marginLeft="50px"                android:layout_marginRight="50px"                android:src="@mipmap/head" />            <TextView                android:clickable="false"                android:focusableInTouchMode="false"                android:focusable="false"                android:id="@+id/classmate_name"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:layout_marginTop="20px"                android:text="hugh"                android:textColor="@color/color_333333"                android:textSize="16sp" />            <LinearLayout                android:clickable="false"                android:focusableInTouchMode="false"                android:focusable="false"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_marginTop="40px"                android:gravity="center">                <TextView                    android:clickable="false"                    android:focusableInTouchMode="false"                    android:focusable="false"                    android:id="@+id/classmate_jinpai"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:drawableTop="@mipmap/jaingpai"                    android:gravity="center"                    android:text="150"                    android:textColor="@color/green"                    android:textSize="16sp" />                <TextView                    android:clickable="false"                    android:focusableInTouchMode="false"                    android:focusable="false"                    android:id="@+id/classmate_rank"                    android:layout_width="wrap_content"                    android:layout_height="wrap_content"                    android:layout_marginLeft="50px"                    android:drawableTop="@mipmap/paiming"                    android:gravity="center"                    android:text="1"                    android:textColor="@color/green"                    android:textSize="16sp" />            </LinearLayout>        </LinearLayout>    </android.support.v7.widget.CardView></LinearLayout>
0 0
原创粉丝点击