How to add divider in ListView

In order for this code snippet to work, you must add item names starting with “-” where you want to add a divider.

public View getView(int position, View convertView, ViewGroup parent) {
                View divider = mInflater.inflate(R.layout.progressbar, null);
                return divider;
//Implement the rest of the getView here

Android ListView black background when scrolling problem

ListViews in Android as explained here uses Android’s black color as the default background. If you change this background the default behavior is for the ListView to cache the default color for optimazation.

To fix this issue, all you have to do is either disable the cache color hint optimization, if you use a non-solid color background, or set the hint to the appropriate solid color value. This can be dome from code or preferably from XML, by using the android:cacheColorHint attribute. To disable the optimization, simply use the transparent color #00000000.


<ListView android:id="@android:id/list" android:layout_width="fill_parent"
		android:layout_height="fill_parent" android:layout_weight="1"
		android:layout_gravity="top" android:cacheColorHint="#00000000">