首先说明一下我想实现的功能:

点击某个item之后,让其颜色发生变化。如果变化网上有很多例子,我就不班门弄斧了。Listview之所以点击没有反应是因为上图中绿色部分(自己定义的一个继承BaseAdapter的adapter来适应listview)将listview的item覆盖了。现在点击的只是自定义的adapter中的convertView。

其次,自定义的adapter中包含一个ImageView和二个TextView。代码如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#fcfcfc"

android:orientation="vertical"

android:padding="6dp"

android:descendantFocusability="blocksDescendants">

<RelativeLayout

android:layout_width="match_parent"

android:layout_height="60dp"

android:background="@drawable/mm_listitem"

android:focusable="false"

android:gravity="center_vertical" >

<ImageView

android:id="@+id/userPhoto"

android:layout_width="55dp"

android:layout_height="55dp"

android:layout_alignParentLeft="true"

android:layout_centerVertical="true"

android:paddingLeft="5dp"

android:src="@drawable/xiaohei" />

<TextView

android:id="@+id/friendName"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_toRightOf="@id/userPhoto"

android:padding="7dp"

android:textColor="#000" />

<TextView

android:id="@+id/sendTime"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:padding="7dp"

android:textColor="#666" />

<TextView

android:id="@+id/friendState"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_toRightOf="@id/userPhoto"

android:padding="7dp"

android:textColor="#666" />

</RelativeLayout>

</LinearLayout>

解决办法:

在上面的xml中的LinearLayout中添加

即可以解决。

然后点击可以Toast点击的那个item。

自定义的adapter的getView没有做任何修改。

android中listview点击事件失效的灵异事件的更多相关文章

  1. android中ListView点击和里边按钮点击不能同时生效问题解决

    今天遇到一个问题:android中ListView点击和里边button点击不能同时生效问题解决. 原因是: listView 在开始绘制的时候,系统首先调用getCount()函数,根据他的返回值得 ...

  2. Android中Listview点击item不变颜色以及设置listselector 无效

    Android中Listview点击item不变颜色以及设置listselector 无效 这是同一个问题,Listview中点击item是会变颜色的,因为listview设置了默认的listsele ...

  3. [转]android中listview点击事件失效

    首先说明一下我想实现的功能: 点击某个item之后,让其颜色发生变化.如果变化网上有很多例子,我就不班门弄斧了.Listview之所以点击没有反应是因为上图中绿色部分(自己定义的一个继承BaseAda ...

  4. android中listview点击事件的监听实现

    listview_bookmark.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public vo ...

  5. Android中ListView中有button,checkbox,GridView时事件问题

    最近做项目,用到了listview的item的一些问题,现在抽空把它们总结一下: 转载请表明出处:http://blog.csdn.net/wdaming1986/article/details/67 ...

  6. android中listview点击监听器onItemClick四个参数的含义

    public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) X, Y两个listvie ...

  7. android中ListView控件&&onItemClick事件中获取listView传递的数据

    http://blog.csdn.net/aben_2005/article/details/6592205 本文转载自:android中ListView控件&&onItemClick ...

  8. Android中ListView无法点击

    Android中ListView无法点击 转自:http://xqjay19910131-yahoo-cn.iteye.com/blog/1319502   问题描述: ListView中Item加入 ...

  9. 解决listview点击item失效

    开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承BaseAdapter,在adapter中按照需求进行编写,问题就出现了 ...

随机推荐

  1. 【BZOJ 3566】 3566: [SHOI2014]概率充电器 (概率树形DP)

    3566: [SHOI2014]概率充电器 Description 著名的电子产品品牌 SHOI 刚刚发布了引领世界潮流的下一代电子产品——概率充电器:“采用全新纳米级加工技术,实现元件与导线能否通电 ...

  2. [BZOJ2402]陶陶的难题II(树链剖分+线段树维护凸包+分数规划)

    陶陶的难题II 时间限制:40s      空间限制:128MB 题目描述 输入格式 第一行包含一个正整数N,表示树中结点的个数. 第二行包含N个正实数,第i个数表示xi (1<=xi<= ...

  3. HDU 1057 What Are You Talking About trie树 简单

    http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意 : 给一个单词表然后给一些单词,要求翻译单词表中有的单词,没有则直接输出原单词. 翻译文段部分get ...

  4. 【推导】zoj3981 Balloon Robot

    题意:一个桌子有m个位置(首尾相接),有n支队伍坐在其中的n个位置上.有个机器人会从某个起始位置出发,每个时刻会依次发生以下三个事件: 机器人顺时针转一个单位: 某些队伍通过了题目(如果存在): 如果 ...

  5. Android UI设计规范之知识点

    界面尺寸 android的尺寸众多,建议使用分辨率为720×1280的尺寸设计.这个尺寸720×1280中显示完美,在1080×1920中看起来也比较清晰;切图后的图片文件大小也适中,应用的内存消耗也 ...

  6. Linux可以明文传输密码的工具sshpass

    普通ssh只能手动输入密码,但是sshpass可以明文指定密码,但不建议使用,太不安全了.

  7. MAC 版本 phpstorm 配置 theme

    mac 版本的配置文件在:./Library/Preferences/WebIde70/colors/ 将文件复制到这个目录中,然后phpStorm设置中,IDE设置->editor->f ...

  8. C#利用NPOI在同一个Excel文件中创建多个sheet

    借用NPOI来实现,要在同一Excel文件中创建多个sheet,只需要在同一个workbook中创建多个sheet即可.要注意的是,sheet的名字一定不能重复.下面是实现的代码: private v ...

  9. HDU 3966 Aragorn's Story (树链剖分+树状数组)

    Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  10. Virtual Treeview - Paint cycles and stages

    The most complex process in Virtual Treeview is without doubts its painting. Read here what stages V ...