zoukankan      html  css  js  c++  java
  • 取消GridView/ListView item被点击时的效果

    方法一,在控件被初始化的时候设置

    1
    2
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    listView.setSelector(new ColorDrawable(Color.TRANSPARENT));

    方法二,在布局文件中设置listSelector属性

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <GridView
            android:listSelector="@android:color/transparent"
            android:numColumns="auto_fit"
            android:columnWidth="50dp"
            android:stretchMode="spacingWidth"
            android:layout_weight="1.0"
            android:layout_height="0dip"
            android:layout_width="match_parent"/>
     
    <ListView
            android:listSelector="@android:color/transparent"
            android:layout_height="match_parent"
            android:layout_width="match_parent"/>

    当然也可以定制化自己想要的效果。 

    推荐使用方法二,解耦逻辑代码与布局文件。

  • 相关阅读:
    面向对象-类
    模块04
    总结
    昨天的新的解决方法
    感冒了~ vs中py和vb实现一个小算法
    vs2015社区版不支持installshield
    网站被黑了
    2018/11/18(python)
    2018/11/14
    2018/11/12(python)
  • 原文地址:https://www.cnblogs.com/cmblogs/p/4462983.html
Copyright © 2011-2022 走看看