/**
  * If the adapter's list-view is hosted inside a parent(/grand-parent/etc) that can scroll
  * horizontally, horizontal swipes won't work, because the parent will prevent touch-events from
  * reaching the list-view.
  *
  * <p>If a list-item view has a child with the given resource-ID, the user can still swipe the
  * list-item by touching that child. If the user touches an area outside that child (but inside
  * the list-item view), then the swipe will not happen and the parent will do its job instead
  * (scrolling horizontally).
  *
  * @param childResId The resource-ID of the list-items' child that the user should touch to be
  *     able to swipe the list-items.
  */
 public void setTouchChild(final int childResId) {
   mResIdTouchChild = childResId;
   if (mListView instanceof DynamicListView) {
     DynamicListView dynListView = (DynamicListView) mListView;
     dynListView.setDynamicTouchChild(mResIdTouchChild);
   }
 }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_anim_activity_draganddrop);

    DynamicListView listView = (DynamicListView) findViewById(R.id.activity_draganddrop_listview);
    listView.setDivider(null);

    TextView headerView = new TextView(this);
    headerView.setText("HEADER");
    listView.addHeaderView(headerView);

    final ArrayAdapter<Integer> adapter = createListAdapter();
    AlphaInAnimationAdapter animAdapter = new AlphaInAnimationAdapter(adapter);
    animAdapter.setInitialDelayMillis(300);
    animAdapter.setAbsListView(listView);
    listView.setAdapter(animAdapter);

    Toast.makeText(this, "Long press an item to start dragging", Toast.LENGTH_LONG).show();
    listView.setOnItemMovedListener(
        new DynamicListView.OnItemMovedListener() {
          @Override
          public void onItemMoved(final int newPosition) {
            Toast.makeText(
                    getApplicationContext(),
                    adapter.getItem(newPosition) + " moved to position " + newPosition,
                    Toast.LENGTH_SHORT)
                .show();
          }
        });
  }
 /**
  * If the adapter's list-view is hosted inside a parent(/grand-parent/etc) that can scroll
  * horizontally, horizontal swipes won't work, because the parent will prevent touch-events from
  * reaching the list-view.
  *
  * <p>Call this method with the value 'true' to fix this behavior. Note that this will prevent the
  * parent from scrolling horizontally when the user touches anywhere in a list-item.
  */
 public void setIsParentHorizontalScrollContainer(
     final boolean isParentHorizontalScrollContainer) {
   mIsParentHorizontalScrollContainer = isParentHorizontalScrollContainer;
   if (mListView instanceof DynamicListView) {
     DynamicListView dynListView = (DynamicListView) mListView;
     dynListView.setIsParentHorizontalScrollContainer(mIsParentHorizontalScrollContainer);
   }
 }
  @Override
  public void setAbsListView(final AbsListView listView) {
    mListView = listView;

    if (mDecoratedBaseAdapter instanceof ListViewSetter) {
      ((ListViewSetter) mDecoratedBaseAdapter).setAbsListView(listView);
    }

    if (mListView instanceof DynamicListView) {
      DynamicListView dynListView = (DynamicListView) mListView;
      dynListView.setIsParentHorizontalScrollContainer(mIsParentHorizontalScrollContainer);
      dynListView.setDynamicTouchChild(mResIdTouchChild);
    }
  }