Search code examples
javaandroiddrag-and-dropstatusbar

How to stop dragged items disappearing when dropped on status bar or on screen buttons


I am a bit stuck with a problem:

I am making a drag and drop list reorder (Linear Layouts, not listview) and it is going well, but on my phone I have a status bar a the top and onscreen buttons (backspace etc..), so when I drop a dragged view on the statusbar or bottom buttons it disappears. I have tried using DragEvent.ACTION_DRAG_EXITED to then delete the view before it is dragged over the status bar etc.. but, it causes a Null Pointer exception and I presume that you cannot delete a view when it is being dragged.

Is there a way that I can either stop users dragging views over the status bar / buttons or can I delete a dragged view in DragEvent.ACTION_DRAG_EXITED?

Any help will be appreciated, thanks in advance!


Solution

  • Try to hide status bar when you fire drag event .

    http://developer.android.com/training/system-ui/status.html#behind