Gridview的item含有checkbox,setOnItemClickListener方法失效的问题

简介: <p>在开发中我们常常遇到一些莫名奇妙的问题,就比如Gridview的item含有checkbox,setOnItemClickListener方法失效的问题。</p> <p>刚开始网上搜了一下,如http://my.oschina.net/fuckboogie/blog/346202</p> <p>按这个没办法解决我上面的问题,于是我在item的子布局里面新增了</p> <p></

在开发中我们常常遇到一些莫名奇妙的问题,就比如Gridview的item含有checkbox,setOnItemClickListener方法失效的问题。

刚开始网上搜了一下,如http://my.oschina.net/fuckboogie/blog/346202

按这个没办法解决我上面的问题,于是我在item的子布局里面新增了

<span style="font-size:18px;">android:descendantFocusability="blocksDescendants"</span>

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/picture_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:descendantFocusability="blocksDescendants"
    android:layout_centerInParent="true">

    <ImageView
        android:id="@+id/album_item_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop" />

    <CheckBox
        android:id="@+id/select_tag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/album_item_image"
        android:layout_alignTop="@+id/album_item_image"
        android:layout_margin="5dp"
        android:button="@null"
        android:clickable="false"
        android:background="@drawable/picture_selector" />
</RelativeLayout></span>

然后问题就解决了


目录
相关文章
ListView Item多布局的实现
ListView这个小节的最后一节,给大家带来的是ListView多布局Item的实现, 何为ListView Item多布局,打个比方,QQ这种聊天列表
110 0
ListView 中Checkbox 错乱问题
最近项目需求,模仿今日头条的短视频播放,点击其中一个视频,将其他的视频停止播放。撸完代码后执行,发现会发现图片错位的情况,然后去谷歌,寻求解决,大多数都是setTag()方式,可以试过后还是存在问题。
737 0
ListView+CheckBox错乱问题
public class MyAdapter extends BaseAdapter { private Context mContext; private ArrayList&lt;Map&lt;String, Object&gt;&gt; data; public static HashMap&lt;Integer, Boolean&gt; mapisSelector;
1354 0
|
Android开发
Gridview的item含有checkbox,setOnItemClickListener方法失效的问题
在开发中我们常常遇到一些莫名奇妙的问题,就比如Gridview的item含有checkbox,setOnItemClickListener方法失效的问题。 刚开始网上搜了一下,如http://my.oschina.net/fuckboogie/blog/346202 按这个没办法解决我上面的问题,于是我在item的子布局里面新增了 &lt;span style="font-size
892 0
winform中textbox属性Multiline=true时全选
1、文本框右键属性 => 添加KeyDown事件。 2、添加如下代码: private void txt_result_KeyDown(object sender, KeyEventArgs e) { if (e.
884 0