GridView items are displaying the wrong drawables sometimes.

Posted by originalbryan on Stack Overflow See other posts from Stack Overflow or by originalbryan
Published on 2010-05-29T20:11:24Z Indexed on 2010/05/29 20:12 UTC
Read the original article Hit count: 276

Filed under:
|

I've implemented a GridView based on this tutorial. It works great unless open up the search dialog or rotate the screen then scroll around.

When the search dialog and virtual keyboard appear, the drawables for each of my grid items shift. I can click on them and they do what I expect, except the drawable is wrong.

The same problem happens when I go into landscape mode and scroll around. If I scroll down, up, the down again, the drawables are shuffled.

For better illustration, let's say I have three objects, each with an image.

  • Obj A shows an Apple
  • Obj B shows a Banana
  • Obj C shows a Cantaloupe

When the shift occurs I end up with:

  • Obj A shows an Cantaloupe
  • Obj B shows a Banana
  • Obj C shows a Apple

The problem isn't consistent between the two causes (search dialog and screen rotate n' scroll), but each cause itself is consistent. Scrolling around repeatedly reveals a pattern as does the search dialog appearing. How can I stop this from happening?

© Stack Overflow or respective owner

Related posts about android

Related posts about gridview