setOnItemClickListener+自定义item点击无响应

//
//根布局设置 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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值