Flag skipped cells GridView

213 Views Asked by At

Is there a possibility to Flag skipped cells so that the Position in method getView(BaseAdapter) doesn't count them anymore. Because skip cells without marking them as skipped or "empty" can lead into NPE providing your payload(for example from an Drawable-Array... Searched stack and just found an example where he wanted to also skip to the next source... I don't want that.

See link Android gridview skip cell

Update:

enter image description here

This will make it completely clear to you :)

THe Problem is, i can scale the Images..so that means..regarding to the Screen width, just a specified amount of Images fit in one row. Hope you can give me Support :)

1

There are 1 best solutions below

12
On

If I'm understanding you correctly, you are asking if there is a way to simply ignore certain items passed into the adapter for a GridView? No there is not. You would have to remove the items you wish to skip from the adapter. Otherwise, you could do what that link suggested in that you simply draw a blank space for any item you want to skip.

Update

Well, when I put my idea for you on paper it didn't pan out. The ultimate solution requires some heavy customization on not just the adapter side but also on the widget side. What you need (and what I was trying to do) is a way to organize the images via it's ordering type. So you'd have a list of images for those that start with 'a'. And another list of images for those that start with 'b'. Then use a Map of the ordering type to find those lists. The problem is that the normal ListAdapter just doesn't cater to this setup. What would is an ExpandableListAdapter. Your problem could easily be solved with an ExpandableListView if it supported GridView

I found this post where the code for a custom ExpandableGridView was created. The person posting the question was looking for a solution for a similar problem. I suggest trying it out and seeing if it works for you.

There's also this open source library that seems to have a lot of attention: ExpandableGridView