zoukankan      html  css  js  c++  java
  • Android,LIstView中的OnItemClick点击无效的解决办法

    在List_Item布局文件中的根节点加上如下背景标黄的这一行

    <?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:orientation="vertical"
        android:descendantFocusability="blocksDescendants"
        android:background="@null">

    如果你的自定义ListViewItem中有Button或者Checkable的子类控件的话,那么默认focus是交给了子控件,而ListView的Item能被选中的基础是它能获取Focus,也就是说我们可以通过将ListView中Item中包含的所有控件的focusable属性设置为false,这样的话ListView的Item自动获得了Focus的权限,也就可以被选中了(来源:http://www.cnblogs.com/ycxyyzw/p/3672366.html)

    但实际上,我的List_Item中有ImageButton 

    这个是当初布局的时候随手一拖的,也没有用。结果就这样了。所以布局List_Item时还是要小心点。

  • 相关阅读:
    Linux免密码登陆
    Java事务的概念
    SpringMVC访问静态资源
    堆排序
    滚动视图 UIScrollView
    HTML数据解析
    同步下载 异步下载
    项目中的小心得(以后慢慢积累起来)
    xcode 中 UIbutton图片的放置
    NSobject的基本方法使用
  • 原文地址:https://www.cnblogs.com/atwind/p/4548571.html
Copyright © 2011-2022 走看看