ListView是Android开发用到最多的空间了,之前就遇到过拖动ListView变黑的情况,那时是在layout里面写的:

copy

  1. <ListView android:id="@android:id/list"  

  2.                android:layout_width="fill_parent"   

  3.                android:layout_height="fill_parent"  

  4.                android:layout_weight="1"  

  5.                 android:background="#C0C0C0"  

  6.                android:drawSelectorOnTop="false"  

  7.                android:cacheColorHint="#00000000"/>  


 android:background="#C0C0C0"当改变了原有的背景颜色,要加上android:cacheColorHint="#00000000",透明度为0

今天就遇到一种情况是这个Activity继承了ListActivity然后没有layout,这时候就要在代码里面写了:

[java] view plaincopy

  1. this.getListView().setBackgroundColor(0xffc0c0c0);  

  2. getListView().setCacheColorHint(0);  

转:http://blog.csdn.net/a859522265/article/details/7695336