Disappearing divider in ListView when ArrayAdapter.isEnabled returns false
This worked for me. This will show the divider as well as disable the click on list item. Even in Android 5.0.
Set this on the list item
android:focusable="true"
android:clickable="false"
Setting just clickable to 'false' didn't work for me. And Overriding isEnabled() caused the above mentioned issue of hiding the divider in 5.0.
And my ListView looks like this.
<ListView
android:id="@+id/lvItems"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@color/Gray"
android:dividerHeight="1px">
</ListView>
No android:listSelector="@android:color/transparent"
needed here
Return true in areAllItemsEnabled() and false in isEnabled for specific item. The disabled item wont be clickable but you will still be able to view the divider lines
Note: This doesn't work for Android 5
You can essentially disable a list item by giving any one of its elements the following properties.
android:focusable="true"
android:clickable="true"
So the following list item layout will not be clickable, but will show dividers, without the need to implement areAllItemsEnabled()
or isEnabled(int position)
.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:focusable="true"
android:clickable="true">
<TextView
android:text="Large Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
This may help in Android 5.0 where the original answer no longer seems to work.