I'm using ListActivity
with my own ArrayAdapter
class. When I override the methods ArrayAdapter.areAllItemsEnabled()
and ArrayAdapter.isEnabled()
the divider between some cells in the list view disappear. Does anyone know how to avoid this? I need the dividers to display even for disabled cells.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With