0

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

Community
  • 1
  • 1
Mike
  • 857
  • 1
  • 7
  • 11

1 Answers1

1

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

Community
  • 1
  • 1
Ifrit
  • 6,791
  • 8
  • 50
  • 79
  • Yeah I've already done...more trying that but this, in my opionion, completely destroys the Performance of a the gridview.. because i Need many if-Statements.. maybe i'm not completely using the hole functions of the BaseAdapter implementing my idea in a higher Performance way... if you got any idea how to implement that the best way.. feel free to put a Little code or Suggestion that would be great.. my Goal is to sort the Images alphabetically.. so it must be dynamically because the amount of Images can Change at time if user adds another Image with a new Label... thank you @Jay Soyer – Mike Nov 15 '14 at 12:45
  • the amount of Images Change at time...and if the next Letter is reached..for example all Images with startLetter A are viewed i Need to skip into the next row(fill current row with empty items) and add the next first Image with startletter B there..and so on.. maybe you got something..i would appreciate that @Jay Soyer – Mike Nov 15 '14 at 12:46
  • I think I get what you are saying. Basically you only want rows to contain all of one sorting type. So all images that start with A will only be on rows with other images that start with A. A new row should start when coming across an image that starts with B. In addition, list of images will constantly be in flux? – Ifrit Nov 15 '14 at 14:05
  • Yes correct! :) i've updated my question to give you a better overview – Mike Nov 15 '14 at 14:25
  • Gotcha. Final questions, will you always follow sorting based on the first letter in the label text? Or are you following of a different sort logic? I think i have a solution for you. – Ifrit Nov 15 '14 at 15:45
  • Yes, but later i will also allow my users to sort on other conditions but this won't have anything to do with the Labels of the Images.. it's another chapter but don't worry about that. :) – Mike Nov 15 '14 at 15:50
  • Ok. Give me a bit to work out my solution and type up the answer. Will hopefully have it to you NLT tomorrow. – Ifrit Nov 15 '14 at 17:35
  • would be really nice! Thank you – Mike Nov 15 '14 at 17:44
  • @Mike, posted an update to my answer. My original idea didn't pan out. :-( – Ifrit Nov 16 '14 at 12:33
  • thank you for your time, is it possible to take a listview with and expandableBaseAdapter or would the items just Show the childs(ImageViews)(expand the childs) when i click on the item? Anyway for your time, your help i gave you an upvote! So what i mean i now stepped to a ListView and went away from a gridview. The ListView inflate a Layout for each Item which contains a relativelayout with 4 imagesviews...but then theres the next Problem, if you got time would be nice if you read: – Mike Nov 16 '14 at 12:41
  • http://stackoverflow.com/questions/26953392/listview-using-multiple-subitems?noredirect=1#comment42448353_26953392 – Mike Nov 16 '14 at 12:41
  • Only an ExpandableListView can accept an ExpandableBaseAdapter. Will check out your other posting. – Ifrit Nov 16 '14 at 12:43