Did you try changing the order of setSelection() and requestFocus()?

Did you try calling draggableGrid.invalidate() after setSelection() and requestFocus()?

Yes, I tried all of them, but nothing worked.

OK, one more thing you could try, and then I'm out of ideas.

When you remove the last item from the grid view, call setFocusable(false) and setFocusableInTouchMode(false) on it *before* calling requestFocus() elsewhere. That way, it should *never* be able to get the focus back. When you add items back to it, you can set them both to true again.

Bear in mind, the problem might not be to do with focus - it might be that - whether it has the focus or not - it insists on drawing the 'selected item' no matter what - even if it has no selection, or no items to show. It's possible that it doesn't like being empty, and expects at least one item in it.

A final possibility is to create a class that extends GridView, and override onDraw(). When it has no items in it, do *not* call the superclass version (as you would under normal circumstances). That should prevent it from drawing the selection indicator - but it may also prevent it from drawing the background (but you could compensate for that by manually drawing the background only).

The problem may simply be that you are using it in a way it is not designed for (empty grid views) - so we are fighting the system.

After that, you're going to have to hope someone else on here has some suggestions...


--
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

Reply via email to