drag-sort-listview
drag-sort-listview copied to clipboard
No empty view when list view is empty
Empty view does not show after verifying that the list view is indeed empty.
Works for me. Could you give some more details? Are you making sure to use dslv in a ListActivity or ListFragment?
Are you using a subclass of DragSortCursorAdapter? If you've made your own adapter, are you sure that getCount()
returns zero when it should?
I do use it in a ListFragment. I do not use a subclass of DragSortCursorAdapter, as I use a subclass of ArrayAdapter. getCount() does return 0, when there are no items in the list, and it returns the correct count when there are items in the list. I use the same empty view base that I use in other lists, pull to refresh lists, etc. This is the the only list, that I have to manually insert an empty view using the header as a work around. Thank you for your work on this, as I do use this as part of my home view.
Unfortunately I cannot help any further unless I am able to reproduce your issue. Could you please put together a minimal example that reproduces the problem.
Modifying one of the demos might be the easiest.
I bit late but if someone faces this problem, I solved it using this layout definition for the fragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.mobeta.android.dslv.DragSortListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:name="com.narubane.timi.FragtimiFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:animateLayoutChanges="false"
android:cacheColorHint="#00000000"
android:choiceMode="none"
android:divider="@color/md_divider"
android:dividerHeight="@dimen/dimSpaceBetweenRows"
android:focusable="false"
android:focusableInTouchMode="false"
android:longClickable="true"
android:padding="0dp"
dslv:click_remove_id="@+id/click_remove"
dslv:collapsed_height="1px"
dslv:drag_enabled="true"
dslv:drag_handle_id="@+id/textViewDragFragtimi"
dslv:drag_scroll_start="0.33"
dslv:drag_start_mode="onMove"
dslv:float_alpha="0.6"
dslv:remove_enabled="true"
dslv:remove_mode="clickRemove"
dslv:slide_shuffle_speed="0.3"
tools:context="com.narubane.timi.FragtimiFragment"
tools:listitem="@layout/row_fragtimi_layout" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/CounterColor"
android:gravity="center_vertical|center_horizontal"
android:padding="8dp"
android:theme="@style/AppTheme">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="@string/empty_fragtimis_list" />
</LinearLayout>
</LinearLayout>
Notice specially the ids: android:id="@android:id/list"
in the list layout and android:id="@android:id/empty"
for the empty view.
valba8 [email protected] 於 2017年2月20日 週一 下午9:44 寫道:
I bit late but if someone faces this problem, I solved it using this layout definition for the fragment:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<com.mobeta.android.dslv.DragSortListView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:dslv="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@android:id/list" android:name="com.narubane.timi.FragtimiFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="0dp" android:animateLayoutChanges="false" android:cacheColorHint="#00000000" android:choiceMode="none" android:divider="@color/md_divider" android:dividerHeight="@dimen/dimSpaceBetweenRows" android:focusable="false" android:focusableInTouchMode="false" android:longClickable="true" android:padding="0dp" dslv:click_remove_id="@+id/click_remove" dslv:collapsed_height="1px" dslv:drag_enabled="true" dslv:drag_handle_id="@+id/textViewDragFragtimi" dslv:drag_scroll_start="0.33" dslv:drag_start_mode="onMove" dslv:float_alpha="0.6" dslv:remove_enabled="true" dslv:remove_mode="clickRemove" dslv:slide_shuffle_speed="0.3" tools:context="com.narubane.timi.FragtimiFragment" tools:listitem="@layout/row_fragtimi_layout" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/CounterColor" android:gravity="center_vertical|center_horizontal" android:padding="8dp" android:theme="@style/AppTheme"> <TextView android:id="@+id/textView9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_vertical|center_horizontal" android:text="@string/empty_fragtimis_list" /> </LinearLayout>
Notice specially the ids: android:id="@android:id/list" in the list layout and android:id="@android:id/empty" for the empty view.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bauerca/drag-sort-listview/issues/70#issuecomment-281082526, or mute the thread https://github.com/notifications/unsubscribe-auth/AQpm-jpxwn3yKdPp6u0IIU3T6XPwTMShks5reZisgaJpZM4AZfa9 .