ListView selectionbehavior erratic

5 posts, 0 answers
  1. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 14 May 2015 Link to this post

    I have implemented RadListview and enabling selection mode by longpressing an item works perfectly fine in the emulator, however, on 3 different models of real devices the longpress enables the selection mode just for a split second and immediately disables it.

     

  2. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 14 May 2015 in reply to Alex Link to this post

    I see in the call stack that it was behavior.onLongPressDrag that executed endSelection().

    For some reason, while the longpress is still going on, it detects a single touch event

  3. DevCraft banner
  4. Todor
    Admin
    Todor avatar
    778 posts

    Posted 15 May 2015 Link to this post

    Hi Aleksandar,

    Thank you for writing.

    The default implementation of the SelectionBehavior indeed ends the selection when you perform a drag gesture while in long press. The idea behind this is to support having both SelectionBehavior and ItemReorderBehavior - when this is the case when you long press - you select and if you start dragging we assume that your intention was to reorder and cancel the selection. If you don't plan to reorder items and just need selection, you can easily create your own behavior which extends SelectionBehavior and simply override its onLongPressDrag, where you should simply leave the method body empty.

    If you don't actually perform drag, but the selection ends anyway, my guess is that you are showing ActionMode when the selection starts, but your activity doesn't have an ActionBar. If that is the case, when the action mode shows, the whole activity slides down in order to free space for the action mode so the drag occurs not because of your finger moving around, but because of the activity that was moving around. The solution in that case is to make sure that you have an ActionBar which is visible while the ActionMode is not shown as visible in the first image in this documentation article and as is the ActionMode's intended usage. You may also need to manually hide the ActionBar when displaying the ActionMode in order to ensure that one and only one of them is shown at a time.

    I hope this information helps. Don't hesitate to get back to us in case you need further assistance.

    Regards,
    Todor
    Telerik
    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
  5. Alex
    Alex avatar
    54 posts
    Member since:
    Feb 2009

    Posted 15 May 2015 in reply to Todor Link to this post

    Your guess is pretty good. I actually do have an ActionBar, but not the default one, rather the ToolBar.

    However, as you guessed, the RadListView does show the default ActionBar, for a split second, which scrolls the content down making it appear as if I am dragging the finger, and the menu inflated is displayed on it, rather then on my ToolBar which is registered as the ActionBar by calling setSupportActionBar(toolbar)

     How do I make the RadListView inflate the menu on my ToolBar instead of displaying the default one?

  6. Todor
    Admin
    Todor avatar
    778 posts

    Posted 20 May 2015 Link to this post

    Hi,

    It doesn't seem to be possible to inflate the action mode in the toolbar.

    However, we have a similar scenario in our demos application in the selection example for RadListView. What we have done is to set toolbar's visibility to GONE just before we start the action mode and then when onDestroyActionMode is called we set the toolbar's visibility back to VISIBLE. The code of the example is available here.

    Let us know if this doesn't work for you.

    Regards,
    Todor
    Telerik
    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
DevCraft banner