I'm subclassing BaseAdapter to simply serve up images for a GridView based
on internal data.
The main UI allows the user to drag these images 'off' the grid. The drag
image is a separate ImageView vying for Z order with the grid in their
parent layout. Whenever I reposition the drag image using layout(), it
automatically comes to the top and looks as you'd expect.
When the user first clicks the grid and I've worked out which list position
is under the pointer, I am calling a method on the adapter to change the
underlying data to reflect the image having 'gone' from that position. I
thus use notifyDataSetChanged() to flag to the UI that it needs to refresh
from the adapter.
All of this and the dragging mechanism works absolutely fine, with just one
tiny glitch - it seems that notifyDataSetChanged() (or the GridView, which I
assume is an observer) waits for the UI thread to become free before it
actually refreshes the grid - which makes perfect sense. The problem is,
that seems to bring the grid back to the top of the Z order, popping my drag
image to the back. If you click the grid and leave the pointer in that
position for a moment, the image appears to completely disappear until you
move the pointer and the correct Z order is re-established with the drag
image on top.
What is the best way to either
* Be notified that the grid was actually refreshed so that I can manually
re-establish the Z order without waiting for pointer movement,
* Or schedule a call to bringToFront() so that it also goes on the end of
the UI's queue, thus happening after the grid has been refreshed
I.e.,
m_overlayImage.setVisibility(View.VISIBLE); // Drag image first becomes
visible.
m_adapter.setData(gridRowIndex, gridColIndex, 0); <== Calls
notifyDataSetChanged().
m_overlayImage.bringToFront(); <== Can I delay this until the UI thread is
free?
* Or a third option? Is there such a thing as stay-on-top semantics for a
view, or some sort of overlay view with transparency such as desktop Java's
GlassPane that I could add the drag image view to instead? I can't find
anything that looks promising in the docs... so far.
Thanks in advance.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en