Android中取消GridView & ListView默认的点击背景色

方法一:

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

在代码中初始化的时候设置其属性。

方法二:

<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"/>

在布局文件设置android:listSelector设置为透明色,当然既然能设置成透明的,也能用这个属性设置你自己想要的点击背景色!

上一篇:Part 92 Significance of Thread Join and Thread IsAlive functions


下一篇:HDU 4891 The Great Pan (模拟)