ListView是Android开发用到最多的空间了,之前就遇到过拖动ListView变黑的情况,那时是在layout里面写的:
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="#C0C0C0" android:drawSelectorOnTop="false" android:cacheColorHint="#00000000"/>
android:background="#C0C0C0"当改变了原有的背景颜色,要加上android:cacheColorHint="#00000000",透明度为0
今天就遇到一种情况是这个Activity继承了ListActivity然后没有layout,这时候就要在代码里面写了:
this.getListView().setBackgroundColor(0xffc0c0c0); getListView().setCacheColorHint(0);