使用方法:
第一种是在listview中配置
复制代码 android:listSelector="@drawable/list_item_bg"第二种是在listview的item中添加属性 复制代码 android:background="@drawable/list_item_bg"
第三种是java代码中使用:
Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg); listview.setSelector(drawable);
注:列表有时候为黑的情况,需要加上下面的代码使其透明:
复制代码 android:cacheColorHint="@android:color/transparent"
希望本文所述对大家Android程序设计有所帮助。
注:相关教程知识阅读请移步到Android开发频道。










