how to check if the item go over a sticky header or a real list item ?

2 posts, 0 answers
  1. Hasan
    Hasan avatar
    2 posts
    Member since:
    Jul 2016

    Posted 20 Jul 2016 Link to this post

    01.itemReorderBehavior.addListener(new ItemReorderBehavior.ItemReorderListener() {
    02.            @Override
    03.            public void onReorderStarted(int i) {
    04.                from = i-1;
    05.            }
    07.            @Override
    08.            public void onReorderItem(int i, int i2) {
    09.                to = i2-1;
    10.            }
    12.            @Override
    13.            public void onReorderFinished() {
    14.                //Called when the user has released the item being reordered.
    15.            }
    16.        });


    i have sticky header with drag and drop

    how to check if the item go over a sticky header or a real list item ?

  2. Todor
    Todor avatar
    793 posts

    Posted 22 Jul 2016 Link to this post

    Hi Hasan,

    Thank you for your question.

    The sticky header is not a real item, but an image that is drawn on top of the real items. This means that you can't reorder with the sticky header (the image), you can reorder only with a real header (meaning that you have scrolled to the top of the group and placed the reordered item over the actual header).

    If you need to determine if you are reordering with a header, you can use the reorder listener and its onReorderItem method. There you will receive the original position of the item that you reorder and the position its being reordered to. Once you have this position, you can use ListViewDataSourceAdapter's isGroupHeader method, which returns true if the item on the position passed as a parameter is a group header.

    P.S. By default you can't reorder with headers due to the default implementation of the adapter's canReorder method:

    public boolean canReorder(int position) {
        if(!isPositionValid(position)) {
            return false;
        return !isGroupHeader(position);

    If you need to change this behavior, simply override this method with your own implementation.

    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top