bauerca / drag-sort-listview

Android ListView with drag and drop reordering.
3.2k stars 1.44k forks source link

Force clickable value to false #104

Open julesanchez opened 11 years ago

julesanchez commented 11 years ago

Hi,

First of all, I want to thank you for your hard work on this library, which is really useful and fills the drag/drop pattern gap on Android Sdk.

Days ago, I encountered an issue, using the drag-sort-listview : I made and set a custom adapter for a DragSortListView with a ayout file which was something like :

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/wrapProg"
        style="@style/button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
         android:padding="4dp" >

         [.....]

     </RelativeLayout>

The drag/drop did not work, and I started to search why. I found that in my file styles.xml, the class "button" has a parent attribute set to "@android:style/Widget.Button"; which set clickable property to "true". And that's why my code was not working as expected, so I set the clickable value of "button" class to false, and all work perfectly.

It's seems, that having dragSortListView with an item clickable, is pretty useless. That's why a made a fix, to set it programmatically on the library.

I hope my use case will help,

Julien

bauerca commented 11 years ago

You can have a clickable list item if you set your dslv:drag_start_mode to "onDrag" or "onLongPress".

julesanchez commented 11 years ago

When I set drag_start_mode to onLongPress it's not working (drag not enable). And when I set to onDrag, i got this error Error: String types not allowed (at 'drag_start_mode' with value 'onDrag'). Here my xml :

 <?xml version="1.0" encoding="utf-8"?>
 <com.mobeta.android.dslv.DragSortListView
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:dslv="http://schemas.android.com/apk/res/com.instant_tv"
     android:id="@+id/list_meschaines"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:padding="3dp"
     android:layout_margin="3dp"
     android:dividerHeight="2dp"
     dslv:drag_enabled="true"
     dslv:collapsed_height="2dp"
     dslv:drag_scroll_start="0.33"
     dslv:max_drag_scroll_speed="0.5"
     dslv:float_alpha="0.6"
     dslv:slide_shuffle_speed="0.3"
     dslv:track_drag_sort="false"
     dslv:use_default_controller="false" />
bauerca commented 11 years ago

I think I know the problem, but unfortunately do not have much time to fix it. One (possible, untested) solution is for you to use the standard method of detecting list item clicks by using your DSLV in a ListActivity or ListFragment or by registering an OnItemClickListener with your DSLV instance.

The problem is that DragSortController only listens in on the ListView onTouchEvent() method (b/c it's an OnTouchListener). When your list items are clickable, they consume the onTouchEvent() calls, and the controller goes deaf to further touch events.